Joreyk ( IXLLEGACYIXL )
Joreyk ( IXLLEGACYIXL )
CC#
Created by Joreyk ( IXLLEGACYIXL ) on 3/28/2024 in #help
How can i make that
public static void Write<T>(this IYamlStream stream, string key, ref T value, DataStyle style = DataStyle.Any)
where T : struct
{
stream.Serialize(ref key);

var emitter = stream.Emitter;
stream.SerializeContext.Serialize(ref emitter, value, style);

}
public static void Write<T>(this IYamlStream stream, string key, ref T value, DataStyle style = DataStyle.Any)
where T : class
public static void Write<T>(this IYamlStream stream, string key, ref T value, DataStyle style = DataStyle.Any)
where T : struct
{
stream.Serialize(ref key);

var emitter = stream.Emitter;
stream.SerializeContext.Serialize(ref emitter, value, style);

}
public static void Write<T>(this IYamlStream stream, string key, ref T value, DataStyle style = DataStyle.Any)
where T : class
why is this not allowed? isnt the type restriciton enough? i want to differentiate between structs and classes so i have a null check where needed and no unnecessary boxing and stuff
16 replies
CC#
Created by Joreyk ( IXLLEGACYIXL ) on 3/27/2024 in #help
What does happen with nullable
public static void Write(this IYamlStream stream, string Key, ref string? value, ScalarStyle style = ScalarStyle.Any) i have this, what does happen when value is non nullable? is it boxed? can i somehow write an extension method for a nullable value and a non nullable value? when doing so it says that the metohd is allready defined but one method is about a boxed string and the other one isnt so isnt it different in the end?
12 replies
CC#
Created by Joreyk ( IXLLEGACYIXL ) on 1/13/2024 in #help
How to work better with records
https://gist.github.com/IXLLEGACYIXL/e3c5575656de0bebf314096699e9d42c I have this and want the modified item after breakthrough is applied, but i dont want to modify the original item but it seems like this shouldnt be the way to work with records... can i simplify that syntax?
86 replies
CC#
Created by Joreyk ( IXLLEGACYIXL ) on 12/9/2023 in #help
✅ How to Simplify
I have this https://gist.github.com/IXLLEGACYIXL/399c51cf0341188bdc4e02a820c34ce0 I need the generictypedefinitions hash and not the "normal" hashcode of the type now i wrote that to "override" the gethashcode to get the generic one, isnt there a simpler way to achieve that?
21 replies
CC#
Created by Joreyk ( IXLLEGACYIXL ) on 8/24/2023 in #help
Problem with Generics
https://github.com/NexStandard/NexVYaml/tree/master/VYaml.Core/Serialization I dont know how to get further here In the NexYamlSerializerRegistry all Serializers are registered. Like So , tinherit implements iCLoneable but it doesnt matter its just for having an interface
NexYamlSerializerRegistry.Default.RegisterFormatter(new GeneratedYamlSerializerTInherit());
NexYamlSerializerRegistry.Default.RegisterInterface(x, typeof(ICloneable));
NexYamlSerializerRegistry.Default.RegisterFormatter(new GeneratedYamlSerializerTInherit());
NexYamlSerializerRegistry.Default.RegisterInterface(x, typeof(ICloneable));
` Now the https://github.com/NexStandard/NexVYaml/blob/master/VYaml.Core/Serialization/YamlSerializer.cs#L41 serializer calls the redirector because i dont know which path to go when i have Serialize(ICloneable) so i need to find it in the registry and now the trouble starts as i cant search it as the generic type doesnt fit here https://github.com/NexStandard/NexVYaml/blob/master/VYaml.Core/Serialization/Resolvers/RedirectFormatter.cs#L56 because T is ICloneable which and the serialize method uses T value ( the one to serialize ) but i cant convert IYamlFormatter<TInherit> to IYamlFormatter<ICloneable> because of the covariance i guess... i have no clue actually to what i should convert it... in the formatter variable is the correct one there but its just a IYamlFormatter and not the generic one so it doesnt have the Serialize(T value, blabla)
3 replies
CC#
Created by Joreyk ( IXLLEGACYIXL ) on 8/7/2023 in #help
Why does IPAdress storage in objects immediate crash
public class Host
{
public string Name { get; set; }
public IPAddress IP { get; set; }
}
string ip = "127.0.0.1";
IPAddress parsedIP = IPAddress.Parse(ip);
var local = new Host()
{
Name = "localhost",
IP = parsedIP
};
public class Host
{
public string Name { get; set; }
public IPAddress IP { get; set; }
}
string ip = "127.0.0.1";
IPAddress parsedIP = IPAddress.Parse(ip);
var local = new Host()
{
Name = "localhost",
IP = parsedIP
};
IP = parsedIP this line throws an exception that there is a socket error , without any reason, i just cant store an ipaddress objekt inside an objekt
22 replies
CC#
Created by Joreyk ( IXLLEGACYIXL ) on 1/22/2023 in #help
❔ VS doesnt like my Source Generator, idk why
4 replies
CC#
Created by Joreyk ( IXLLEGACYIXL ) on 11/13/2022 in #help
❔ Csharp equivalent of JPA Stored Procedure Persistence
What is something of an equivalent to the java jpa persistence in c# https://www.baeldung.com/spring-data-jpa-stored-procedures it calls a procedure in my MSSQL server and then it converts them to Persistent Objects. i have not found of an equivalent in c# to call stored procedures+ converting them to objects straight away
23 replies