Beispiel #1
0
        public static void Serialize(object target, IFileStream stream)
        {
            if (stream.Mode == SerializeMode.Reading)
            {
                while (true)
                {
                    string name = null;
                    stream.SerializeName(ref name);

                    if (String.IsNullOrEmpty(name) == true ||
                        name == "None")
                    {
                        break;
                    }

                    string type = null;
                    stream.SerializeName(ref type);

                    short unk2 = -1;
                    stream.SerializeValue(ref unk2);

                    if (unk2 != -1)
                    {
                        throw new FormatException();
                    }

                    var start = stream.Position;

                    uint size = 0;
                    stream.SerializeValue(ref size);

                    if (size < 4)
                    {
                        throw new FormatException();
                    }

                    var end = start + size;

                    if (target is GenericObject)
                    {
                        ReadGenericObjectProperty((GenericObject) target, stream, type, size, name);
                    }
                    else
                    {
                        ReadPropertyValue(stream, target, type, name);
                    }

                    if (stream.Position != end)
                    {
                        throw new FormatException();
                    }
                }
            }
            else
            {
                throw new NotSupportedException();
            }
        }
Beispiel #2
0
        public static void Serialize(object target, IFileStream stream)
        {
            if (stream.Mode == SerializeMode.Reading)
            {
                while (true)
                {
                    string name = null;
                    stream.SerializeName(ref name);

                    if (String.IsNullOrEmpty(name) == true ||
                        name == "None")
                    {
                        break;
                    }

                    string type = null;
                    stream.SerializeName(ref type);

                    short unk2 = -1;
                    stream.SerializeValue(ref unk2);

                    if (unk2 != -1)
                    {
                        throw new FormatException();
                    }

                    var start = stream.Position;

                    uint size = 0;
                    stream.SerializeValue(ref size);

                    if (size < 4)
                    {
                        throw new FormatException();
                    }

                    var end = start + size;

                    if (target is GenericObject)
                    {
                        ReadGenericObjectProperty((GenericObject)target, stream, type, size, name);
                    }
                    else
                    {
                        ReadPropertyValue(stream, target, type, name);
                    }

                    if (stream.Position != end)
                    {
                        throw new FormatException();
                    }
                }
            }
            else
            {
                throw new NotSupportedException();
            }
        }
Beispiel #3
0
        public object Deserialize(IFileStream stream)
        {
            uint count = 0;

            stream.SerializeValue(ref count);

            string elementTypeName = null;

            stream.SerializeName(ref elementTypeName);

            short unk2 = -1;

            stream.SerializeValue(ref unk2);

            if (unk2 != -1)
            {
                throw new InvalidOperationException();
            }

            var list = new List <object>();

            for (uint i = 0; i < count; i++)
            {
                var element = _Serializer.Deserialize(stream);
                list.Add(element);
            }
            return(list);
        }
        public object Deserialize(IFileStream stream)
        {
            string value = null;

            stream.SerializeName(ref value);
            return(value);
        }
        public object Deserialize(IFileStream stream)
        {
            string value = null;

            stream.SerializeName(ref value);

            if (Enum.IsDefined(_EnumType, value) == false)
            {
                throw new FormatException(string.Format("'{0}' does not contain a definition for '{1}'", _EnumType, value));
            }

            return((TType)Enum.Parse(_EnumType, value));
        }
Beispiel #6
0
 public object Deserialize(IFileStream stream)
 {
     string typeName = null;
     stream.SerializeName(ref typeName);
     uint valueSize = 0;
     stream.SerializeValue(ref valueSize);
     var serializer = PropertySerializer.GetSerializer(typeName);
     if (serializer != null)
     {
         var value = serializer.Deserialize(stream);
         return value;
     }
     stream.Position += valueSize - 4;
     return null;
 }
Beispiel #7
0
        public object Deserialize(IFileStream stream)
        {
            string typeName = null;

            stream.SerializeName(ref typeName);
            uint valueSize = 0;

            stream.SerializeValue(ref valueSize);
            var serializer = PropertySerializer.GetSerializer(typeName);

            if (serializer != null)
            {
                var value = serializer.Deserialize(stream);
                return(value);
            }
            stream.Position += valueSize - 4;
            return(null);
        }
Beispiel #8
0
 public object Deserialize(IFileStream stream)
 {
     string value = null;
     stream.SerializeName(ref value);
     return value;
 }