Example #1
0
        Headers ReadHeaders(SerializationReader reader)
        {
            Headers result = new Headers();

            result.FullName   = reader.ReadString();
            result.ContentLen = reader.ReadInt32();

            return(result);
        }
Example #2
0
        public object Deserialize(byte[] array)
        {
            object result = null;

            using (MemoryStream ms = new MemoryStream(array))
            {
                using (SerializationReader sr = new SerializationReader(ms))
                {
                    Headers headers = ReadHeaders(sr);
                    Type    type    = Type.GetType(headers.FullName);

                    ConstructorInfo constructor_info = type.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(SerializationReader) }, null);

                    result = constructor_info.Invoke(new Object[] { sr });
                    //result = Activator.CreateInstance(type, sr);
                }
            }

            return(result);
        }