Deserialize() public method

public Deserialize ( BinaryReader reader ) : object
reader System.IO.BinaryReader
return object
コード例 #1
0
        public static void SerializeObjectNameWithNoParent()
        {
            var objName = new ObjectName("name");

            var serializer = new BinarySerializer();
            byte[] bytes;

            using (var memoryStream = new MemoryStream()) {
                serializer.Serialize(memoryStream, objName);
                memoryStream.Flush();
                bytes = memoryStream.ToArray();
            }

            object graph = null;
            using (var memoryStream = new MemoryStream(bytes)) {
                graph = serializer.Deserialize(memoryStream, typeof(ObjectName));
            }

            Assert.IsNotNull(graph);
            Assert.IsInstanceOf<ObjectName>(graph);

            var objName2 = (ObjectName) graph;
            Assert.AreEqual(objName.Name, objName2.Name);
            Assert.AreEqual(objName, objName2);
        }
コード例 #2
0
        public static void SerializeImplicit()
        {
            var obj = new TestClass2("test2");

            var serializer = new BinarySerializer();
            byte[] bytes;

            using (var memoryStream = new MemoryStream()) {
                serializer.Serialize(memoryStream, obj);
                memoryStream.Flush();
                bytes = memoryStream.ToArray();
            }

            object graph = null;
            using (var memoryStream = new MemoryStream(bytes)) {
                graph = serializer.Deserialize(memoryStream, typeof(TestClass2));
            }

            Assert.IsNotNull(graph);
            Assert.IsInstanceOf<TestClass2>(obj);

            obj = (TestClass2) graph;
            Assert.AreEqual("test2", obj.Value);
            Assert.IsNull(obj.Parent);
        }
コード例 #3
0
        public static T Serialize <T>(T obj)
        {
            var serializer = new BinarySerializer();
            var stream     = new MemoryStream();

            serializer.Serialize(obj, stream);

            stream.Seek(0, SeekOrigin.Begin);

            return((T)serializer.Deserialize(typeof(T), stream));
        }
コード例 #4
0
        private static object Serialize(object value)
        {
            var stream     = new MemoryStream();
            var serializer = new BinarySerializer();

            serializer.Serialize(value, stream);

            stream.Seek(0, SeekOrigin.Begin);

            return(serializer.Deserialize(value.GetType(), stream));
        }
コード例 #5
0
ファイル: SqlUserObjectTests.cs プロジェクト: deveel/deveeldb
        public static void Serialize()
        {
            var obj = Type.NewObject(SqlExpression.Constant(34));

            var serializer = new BinarySerializer();
            var stream = new MemoryStream();
            serializer.Serialize(stream, obj);

            stream.Flush();

            stream.Seek(0, SeekOrigin.Begin);

            var serialized = (SqlUserObject) serializer.Deserialize(stream);

            Assert.IsNotNull(serialized);
            Assert.IsTrue(obj.Equals(serialized));
        }
コード例 #6
0
ファイル: TriggerManager.cs プロジェクト: deveel/deveeldb
 private static InvokeArgument[] DeserializeArguments(byte[] bytes)
 {
     using (var stream = new MemoryStream(bytes)) {
         var serializer = new BinarySerializer();
         var args = (TriggerArgument) serializer.Deserialize(stream);
         return args.Arguments;
     }
 }
コード例 #7
0
ファイル: QueryType.cs プロジェクト: ArsenShnurkov/deveeldb
 private static IQueryPlanNode DeserializePlan(Type nodeType, BinaryReader reader)
 {
     var serializer = new BinarySerializer();
     return (IQueryPlanNode) serializer.Deserialize(reader, nodeType);
 }
コード例 #8
0
        private static object ReadObject(BinaryReader reader, Encoding encoding)
        {
            var objType = ReadType(reader);
            var serializer = new BinarySerializer {
                Encoding = encoding
            };

            return serializer.Deserialize(reader, objType);
        }
コード例 #9
0
ファイル: ViewInfo.cs プロジェクト: ArsenShnurkov/deveeldb
 public static ViewInfo Deserialize(Stream stream)
 {
     var serializer = new BinarySerializer();
     return (ViewInfo) serializer.Deserialize(stream, typeof (ViewInfo));
 }
コード例 #10
0
 internal static SqlExpression Deserialize(BinaryReader reader)
 {
     var serializer = new BinarySerializer();
     return (SqlExpression) serializer.Deserialize(reader, typeof(SqlExpression));
 }
コード例 #11
0
        protected T BinaryDeserialize <T>(Stream stream) where T : class
        {
            var serializer = new BinarySerializer();

            return((T)serializer.Deserialize(stream));
        }
コード例 #12
0
ファイル: ViewInfo.cs プロジェクト: deveel/deveeldb
 public static ViewInfo FromBinary(ISqlBinary binary)
 {
     using (var stream = binary.GetInput()) {
         var serializer = new BinarySerializer();
         return (ViewInfo) serializer.Deserialize(stream);
     }
 }
コード例 #13
0
        protected T BinaryDeserialize <T>(Stream stream) where T : class
        {
            var serializer = new BinarySerializer();

            return(serializer.Deserialize(stream, typeof(T)) as T);
        }