Dultus
Dultus
CC#
Created by Dultus on 10/31/2023 in #help
✅ How do I resolve "Unable to resolve" errors in .NET 8.0?
No description
3 replies
CC#
Created by Dultus on 10/5/2023 in #help
❔ The best way to create custom types?
Hey, what's the best way to implement a custom type? E.g. I want an Id and instead of having it like this:
int id = 12345;
int id = 12345;
I want it like that:
ID id = 12345;
ID id = 12345;
So I don't calculate with the ID for example because it's an ID, not some random number.
15 replies
CC#
Created by Dultus on 5/16/2023 in #help
❔ Best way to wait for a certain time?
Imagine I have a program running on a server and I want to have it do a certain operation at 9am, what's the best way in C# to do so? I'd like to just have an event that triggers at this time. Is there a performance friendly way? I'd probably use a timer with an interval I calculate until it's 9am? Thanks!
5 replies
CC#
Created by Dultus on 4/6/2023 in #help
❔ Get full namespace name
Hey, is there a way to get the full name of a namespace? E.g. nameof(DiscordBarista.Function.Partnership.Events) gives me "Events" but I want "Project_Sipster.DiscordBarista.Function.Partnership.Events" returned.
11 replies
CC#
Created by Dultus on 4/6/2023 in #help
❔ Generalise Attributes?
Is there a way to generalise Attributes? I'd like to create a library in which I can just pass in what Enum to watch out for. So I'd like to replace the EPartnership/ECategory enum with any enum passed into the attribute. What would be the smartest way to get around this?
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class EventPartnershipControllerAttribute : Attribute
{
public EPartnership Event { get; set; }

public EventPartnershipControllerAttribute(EPartnership Event)
{
this.Event = Event;
}
}
public class EventController
{
[EventControllerAttribute(ECategory.PARTNERSHIP)]
public static async void PartnershipController(string[] ids, object e)
{
// Foo...
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class EventPartnershipControllerAttribute : Attribute
{
public EPartnership Event { get; set; }

public EventPartnershipControllerAttribute(EPartnership Event)
{
this.Event = Event;
}
}
public class EventController
{
[EventControllerAttribute(ECategory.PARTNERSHIP)]
public static async void PartnershipController(string[] ids, object e)
{
// Foo...
11 replies
CC#
Created by Dultus on 3/29/2023 in #help
❔ Magnetic Links for application?
Hey, does someone have an article/tutorial/explanation how I can develop magnetic links for my application? E.g. I click on a link or open a website and my application gets called.
5 replies
CC#
Created by Dultus on 3/3/2023 in #help
❔ How to I use my domain for my ASP.NET REST?
Hi, question basically says it all. I don't have current application but I'm curious. I do have a domain on a webspace. So I'd host my application on a different Root Server. I am able to create Subdomains - how would I make my REST Application available from that subdomain?
2 replies
CC#
Created by Dultus on 2/10/2023 in #help
❔ Can't use ToastContentBuilder.Show();
Hey, so I've created a WPF project in .NET 7.0 and wanted to use the Microsoft.Toolkit.Uwp.Notifications package with the ToastContentBuilder. I can't use the Show method for some reason. Documentation says that I should be on version 7.0 (using the newest one 7.1.3 (a downgrade didn't help either)), .NET 6 oder later and at least on net6.0-windows10.0.17763.0 or greater. Again, a downgrade didn't help here either. Someone got an idea?
var test = new ToastContentBuilder()
.AddText("Hello world!");
test.Show(); // Not found
var test = new ToastContentBuilder()
.AddText("Hello world!");
test.Show(); // Not found
5 replies
CC#
Created by Dultus on 1/24/2023 in #help
❔ Is there a way to remove brackets from empty methods?
E.g.
public MismatchedEnumLengthsException() : base("Length of values and enums are different. You are required to pass as many values as there are enums")
{
}
public MismatchedEnumLengthsException() : base("Length of values and enums are different. You are required to pass as many values as there are enums")
{
}
I don't need those brackets. Can't I make this look prettier?
25 replies
CC#
Created by Dultus on 1/24/2023 in #help
❔ Can I generalise this method?
public static IEnumerable<Enum> TransformIdToEnums(string value, params Type[] enums)
{
string[] values = value.Split(',');
for (int i = 0; i < enums.Length; i++)
{
var type = enums[i];
yield return (Enum)Converter.GetEnumFromValue<type>(values[i]);
}
}
public static IEnumerable<Enum> TransformIdToEnums(string value, params Type[] enums)
{
string[] values = value.Split(',');
for (int i = 0; i < enums.Length; i++)
{
var type = enums[i];
yield return (Enum)Converter.GetEnumFromValue<type>(values[i]);
}
}
Lets say I pass in "0,3,2" - I also want to pass in the Types of the Enusm I want to get them converted as. For example I split them into three different Enums, 0 being the category, 3 the subcategory and 2 a list item. Any way to generalise this?
9 replies
CC#
Created by Dultus on 1/3/2023 in #help
❔ Is there any overview of useful attributes and how to use them?
E.g. [Obsolete] or for example where a method is allowed to be used and so on. Basically basic attributes for daily things that are included in common libs like System.
32 replies