A properties serializer for C#
// import the serializer classes
using Dalk.PropertiesSerializer;
using Dalk.PropertiesSerializer;
public class TestObject
{
// use the attribute to specify a custom name
[PropertyName("test_int")]
public int TestInt { get; set; }
public string TestString { get; set; }
public bool TestBool { get; set; }
public SecondTestObject SecondTestObject { get; set; }
}
string properties = Serializer.Serialize(@object);
var @object = Serializer.Deserialize<TestObject>(properties);
using System;
using Dalk.PropertiesSerializer.TypeSerializers;
[TypeSerializer]
public class TestTypeSerializer : ITypeSerializer
{
public object Deserialize(string o) => TestType.Parse(o);
Type type = typeof(TestType);
public Type GetCType() => type;
public string Serialize(object o) => o.ToString();
}
Serializer.LoadTypeSerializersFromAssembly(Assembly.GetAssembly(GetType()));
Serializer.AddCustomTypeSerializer(new TestTypeSerializer());