Tobonautilus
Tobonautilus
CC#
Created by Tobonautilus on 5/13/2024 in #help
Why cannot a nested XML-Element be serialized? What do I miss?
I try to deserialize the YouTube feed. But I cannot get the "group:media" working. It is always null. Do you see any issue with my code? Thanks! Model
[XmlRoot(ElementName = "entry")]
public class Entry
{
[XmlElement(ElementName = "group", Namespace = "media")]
public required Media Media { get; set; }
}

public class Media
{
[XmlElement(ElementName = "title", Namespace = "media")]
public required string Title { get; set; }
}
[XmlRoot(ElementName = "entry")]
public class Entry
{
[XmlElement(ElementName = "group", Namespace = "media")]
public required Media Media { get; set; }
}

public class Media
{
[XmlElement(ElementName = "title", Namespace = "media")]
public required string Title { get; set; }
}
XML
<entry>
<id>yt:video:ZmD1tDVJaAQ</id>
<media:group>
<media:title>I need this property</media:title>
</media:group>
</entry>
<entry>
<id>yt:video:ZmD1tDVJaAQ</id>
<media:group>
<media:title>I need this property</media:title>
</media:group>
</entry>
1 replies
CC#
Created by Tobonautilus on 5/12/2024 in #help
✅ Added CORS feature to Blazor WASM - I cannot find the file to put it in
At first I'm a absolutely beginner, it may just a misuage or that my idea will not work in WASM. What I wanna achieve If the Blazor Wasm Page loads, I want to call a external RSS Feed to be loaded and the resulting data should be rendered. This fails because of a missing CORS-Feature. I googled and Copilot-ed it but I cannot find the spot where I must add it. It is always prints me: To add CORS (Cross-Origin Resource Sharing) to your Blazor WebAssembly application, you’ll need to configure it on the server that hosts your Blazor app, not directly within the Blazor WebAssembly Program.cs But I cannot find the file. My "ProjectName.Wasm" Program.cs looks like:
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddSingleton<LifeService>();
builder.Services.AddSingleton<MediumService>();

await builder.Build().RunAsync();
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddSingleton<LifeService>();
builder.Services.AddSingleton<MediumService>();

await builder.Build().RunAsync();
` ... and I think I do not have the other file that the pilot mentioned? Thanks for your assistant!
4 replies
CC#
Created by Tobonautilus on 4/29/2024 in #help
The combination of `StringEnumConverter` and `EnumMember` does not work
I try to have "speaking values" for my enum values in a JSON file. I tried combining the both annotations from the title, but it does not work and I cannot understand why. Maybe you know something I missed out :). Enum
[JsonConverter(typeof(StringEnumConverter))]
public enum Language
{
[EnumMember(Value = "en")]
English,
[EnumMember(Value = "de")]
German,
[EnumMember(Value = "ende")]
EnglishAndGerman
}
[JsonConverter(typeof(StringEnumConverter))]
public enum Language
{
[EnumMember(Value = "en")]
English,
[EnumMember(Value = "de")]
German,
[EnumMember(Value = "ende")]
EnglishAndGerman
}
Model (shortend)
public partial class ContentCreation
{
[JsonProperty("name")]
public required string Name { get; set; }

[JsonProperty("language")]
public required Language Language { get; set; }
}
public partial class ContentCreation
{
[JsonProperty("name")]
public required string Name { get; set; }

[JsonProperty("language")]
public required Language Language { get; set; }
}
Converter call
return JsonConvert.SerializeObject(myContentCreation);
return JsonConvert.SerializeObject(myContentCreation);
56 replies
CC#
Created by Tobonautilus on 1/16/2024 in #help
Is there any possibility to iterate over all files in wwwroot/myfolder using Blazor WASM?
I know that you can just request a file using a simple web request. For my usage I need "gimme all the (markdown) files that are in this folder in wwwroot. So far, I think my approach aint working out because WASM does not like file access and I could not find any way to have a wildcard web requests which would make just sense for me - and only for me. Thanks for your help!
11 replies
CC#
Created by Tobonautilus on 1/1/2024 in #help
Does .NETZ MAUI rightly have the reputation of being half-baked?
I'm a Swift guy, but I want to re-check on the Microsoft approach after my break up with Xamarin like 5 years ago. I read a lot of Reddit, Twitter and other platforms where long time .NET developers are outraged about the state of .NET MAUI. Some points are valid, like sun settings VS for Mac, etc. Other says that they have a lot of weird work arounds to get a stable PROD app going with MAUI. What's your opinion, do you see MAUI as the go-to-choice for multiplatform apps in the .NET ecosystem? Thanks for your insights!
8 replies