Example #1
0
        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));
        }
Example #2
0
        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));
        }
Example #3
0
        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));
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }
Example #6
0
 public static StageElement Deserialize(string data)
 {
     SerializationMaster.EnsureInit();
     return(SerializationMaster._serializer.Deserialize(data) as StageElement);
 }
Example #7
0
 public static bool ConverterExists(Type forType)
 {
     SerializationMaster.EnsureInit();
     return(SerializationMaster._typeConverters.ContainsKey(forType));
 }
Example #8
0
 public static string Serialize(StageElement item, bool pretty = false)
 {
     SerializationMaster.EnsureInit();
     return(SerializationMaster._serializer.Serialize(item, pretty));
 }