public static T Deserialize <T>(string data) { SerializationMaster.EnsureInit(); StageItem stageItem = SerializationMaster._serializer.Deserialize(data); if (stageItem != null) { return(SerializationMaster.UnstageAndInitialize <T>(stageItem)); } return(default(T)); }
public static T Deserialize <T>(string data, ICollection <IInitializeAfterDeserialization> requiresInit) { SerializationMaster.EnsureInit(); StageItem stageItem = SerializationMaster._serializer.Deserialize(data); if (stageItem == null) { return(default(T)); } return(SerializationMaster.Unstage <T>(stageItem, requiresInit)); }
public static string Serialize <T>(T item, bool pretty = false) { SerializationMaster.EnsureInit(); StageItem stageItem = SerializationMaster.Stage(typeof(T).Name, item); if (stageItem == null) { return(string.Empty); } return(SerializationMaster._serializer.Serialize(stageItem, pretty)); }
private static IStager GetStager(Type forType) { SerializationMaster.EnsureInit(); if (forType.IsGenericType) { forType = forType.GetGenericTypeDefinition(); } else if (forType.IsArray) { forType = typeof(Array); } IStager stager = null; SerializationMaster._typeStagers.TryGetValue(forType, out stager); return(stager); }
private static IValueConverter GetConverter(Type forType) { SerializationMaster.EnsureInit(); if (forType.IsGenericType) { forType = forType.GetGenericTypeDefinition(); } else if (forType.IsEnum) { forType = SerializationMaster._enumType; } IValueConverter valueConverter = null; SerializationMaster._typeConverters.TryGetValue(forType, out valueConverter); return(valueConverter); }
public static StageElement Deserialize(string data) { SerializationMaster.EnsureInit(); return(SerializationMaster._serializer.Deserialize(data) as StageElement); }
public static bool ConverterExists(Type forType) { SerializationMaster.EnsureInit(); return(SerializationMaster._typeConverters.ContainsKey(forType)); }
public static string Serialize(StageElement item, bool pretty = false) { SerializationMaster.EnsureInit(); return(SerializationMaster._serializer.Serialize(item, pretty)); }