Tantrim
Tantrim
CC#
Created by Tantrim on 6/29/2024 in #help
INotifyPropertyChanged
No description
26 replies
CC#
Created by Tantrim on 6/29/2024 in #help
INotifyPropertyChanged
No description
26 replies
CC#
Created by Tantrim on 6/29/2024 in #help
INotifyPropertyChanged
No description
26 replies
CC#
Created by Tantrim on 6/29/2024 in #help
INotifyPropertyChanged
you definitely have me questioning my choice of JSON storage lol. I think I will go ahead with storing in JSON but I might refactor to using SQLite later if I get a wild hair.
26 replies
CC#
Created by Tantrim on 6/29/2024 in #help
INotifyPropertyChanged
individual JSON files will potentially be shared between users as well. The JSON read/write overhead isn't too much of a concern for this app. But I do understand storing data in JSON is far from best practice
26 replies
CC#
Created by Tantrim on 6/29/2024 in #help
INotifyPropertyChanged
maybe SQLite would have been best? I would prefer something very portable without needing a db installed on the machine
26 replies
CC#
Created by Tantrim on 6/29/2024 in #help
INotifyPropertyChanged
I'm using JSON as local data storage. I'm using Config.Net to just make it easier to manipulate the JSON. It's a small application with about 156kb of data spread between around 40 JSON files I didn't want to use a database. I'm not an expert in this by any means but it seemed logical to me.
26 replies
CC#
Created by Tantrim on 6/29/2024 in #help
INotifyPropertyChanged
this is a .Net Maui Blazor Hybrid app that I'm only targetting windows with
26 replies
CC#
Created by Tantrim on 6/29/2024 in #help
INotifyPropertyChanged
I tried using the Observer pattern but that couldn't see updates from within the lists. I need to look into BindingList maybe
26 replies
CC#
Created by Tantrim on 6/29/2024 in #help
INotifyPropertyChanged
and I'm using a library called Config.Net which stores settings locally in json files. I'm using INotifyPropertyChanged to keep the Config.Net class in sync with my actual data model that I manipulate
26 replies
CC#
Created by Tantrim on 6/29/2024 in #help
INotifyPropertyChanged
only on add or remove type functions of new items into list
26 replies
CC#
Created by Tantrim on 6/29/2024 in #help
INotifyPropertyChanged
from my understanding, ObservableCollection doesn't notify when an item inside of a list is modified
26 replies
CC#
Created by Tantrim on 6/29/2024 in #help
INotifyPropertyChanged
You are correct, sorry for my inaccurate vocabulary choice. Do I need to unsubscribe the original subscriber? If so, I'm strugglying to find the syntax
26 replies
CC#
Created by Tantrim on 4/18/2023 in #help
❔ Unable to resolve service type for IHttpClientFactory
if you need anymore information please let me know
5 replies
CC#
Created by Tantrim on 4/18/2023 in #help
❔ Unable to resolve service type for IHttpClientFactory
5 replies
CC#
Created by Tantrim on 4/18/2023 in #help
❔ Unable to resolve service type for IHttpClientFactory
Web App Proj
// Web App Project
// Index.cshtml.cs
public class IndexModel : PageModel
{
private readonly ILogger<IndexModel> _logger;
private readonly IHttpClientFactory _httpClientFactory;

public IndexModel(ILogger<IndexModel> logger, IHttpClientFactory httpClientFactory)
{
_logger = logger;
_httpClientFactory = httpClientFactory;
}


public async Task OnGet()
{
await GetAllContacts();
}

private async Task GetAllContacts()
{
var _client = _httpClientFactory.CreateClient();
var response = await _client.GetAsync("https://localhost:44320/api/Contacts");

List<ContactModel> contacts;

if (response.IsSuccessStatusCode)
{
var options = new JsonSerializerOptions
{
// allows javascript and c# variables to match. Variables in javascript are camelCase and C# is PascalCase
PropertyNameCaseInsensitive = true
};
string responseText = await response.Content.ReadAsStringAsync();

contacts = JsonSerializer.Deserialize<List<ContactModel>>(responseText, options);
}
else
{
throw new Exception(response.ReasonPhrase);
}
}
}
// Web App Project
// Index.cshtml.cs
public class IndexModel : PageModel
{
private readonly ILogger<IndexModel> _logger;
private readonly IHttpClientFactory _httpClientFactory;

public IndexModel(ILogger<IndexModel> logger, IHttpClientFactory httpClientFactory)
{
_logger = logger;
_httpClientFactory = httpClientFactory;
}


public async Task OnGet()
{
await GetAllContacts();
}

private async Task GetAllContacts()
{
var _client = _httpClientFactory.CreateClient();
var response = await _client.GetAsync("https://localhost:44320/api/Contacts");

List<ContactModel> contacts;

if (response.IsSuccessStatusCode)
{
var options = new JsonSerializerOptions
{
// allows javascript and c# variables to match. Variables in javascript are camelCase and C# is PascalCase
PropertyNameCaseInsensitive = true
};
string responseText = await response.Content.ReadAsStringAsync();

contacts = JsonSerializer.Deserialize<List<ContactModel>>(responseText, options);
}
else
{
throw new Exception(response.ReasonPhrase);
}
}
}
5 replies