public object Deserialize(Stream source, string className)
    {
        CLS_Type_Class sClass = m_clsEnv.GetTypeByKeywordQuiet(className) as CLS_Type_Class;

        if (sClass == null)
        {
            throw new NotImplementedException("未实现类型: " + className);
        }

        if (!sClass.compiled)
        {
            RuntimeCompilerClass(className);
        }

        CLS_Content.Value retVal    = (sClass.function as SType).New(m_clsContent, m_emptyParams);
        SInstance         sInstance = (SInstance)retVal.value;

        ProtoReader reader = null;

        try
        {
            reader = ProtoReader.Create(source, null, null, ProtoReader.TO_EOF);
            ReadSInstance(reader, sInstance, m_clsEnv);
            reader.CheckFullyConsumed();
            return(sInstance);
        }
        finally
        {
            ProtoReader.Recycle(reader);
        }
    }
Beispiel #2
0
        public object Deserialize(Stream source, object value, Type type, int length, SerializationContext context)
        {
            bool noAutoCreate = this.PrepareDeserialize(value, ref type);

            using (ProtoReader reader = new ProtoReader(source, this, context, length))
            {
                if (value != null)
                {
                    reader.SetRootObject(value);
                }
                object obj2 = this.DeserializeCore(reader, type, value, noAutoCreate);
                reader.CheckFullyConsumed();
                return(obj2);
            }
        }
        public object Deserialize(ProtoReader source, object value, Type type)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            bool noAutoCreate = PrepareDeserialize(value, ref type);

            if (value != null)
            {
                source.SetRootObject(value);
            }
            object result = DeserializeCore(source, type, value, noAutoCreate);

            source.CheckFullyConsumed();
            return(result);
        }
        public object Deserialize(Stream source, object value, Type type, int length, SerializationContext context)
        {
            bool        noAutoCreate = PrepareDeserialize(value, ref type);
            ProtoReader protoReader  = null;

            try
            {
                protoReader = ProtoReader.Create(source, this, context, length);
                if (value != null)
                {
                    protoReader.SetRootObject(value);
                }
                object result = DeserializeCore(protoReader, type, value, noAutoCreate);
                protoReader.CheckFullyConsumed();
                return(result);
            }
            finally
            {
                ProtoReader.Recycle(protoReader);
            }
        }
Beispiel #5
0
        public object Deserialize(Stream source, object value, Type type, SerializationContext context)
        {
            bool        autoCreate = this.PrepareDeserialize(value, ref type);
            ProtoReader reader     = null;
            object      result;

            try
            {
                reader = ProtoReader.Create(source, this, context, -1);
                if (value != null)
                {
                    reader.SetRootObject(value);
                }
                object obj = this.DeserializeCore(reader, type, value, autoCreate);
                reader.CheckFullyConsumed();
                result = obj;
            }
            finally
            {
                ProtoReader.Recycle(reader);
            }
            return(result);
        }
Beispiel #6
0
        public static T Deserialize(Stream stream, T obj)
        {
            if (_invoke == null)
            {
                return(_default(stream));
            }

            obj = ProtoSerializeHelper <T> .CreateInstance(obj);

            ProtoReader source = null;

            try
            {
                source = ProtoReader.Create(stream, RuntimeTypeModel.Default, null, ProtoReader.TO_EOF);
                source.SetRootObject(obj);
                obj = _invoke(source, obj);
                source.CheckFullyConsumed();
                return(obj);
            }
            finally
            {
                ProtoReader.Recycle(source);
            }
        }