public void CanDeserializeComplexType()
        {
            // Arrange
            var formatter = new ProtoBufFormatter <Company>();
            var graph     = new Company()
            {
                Name      = "Initech Corporation",
                Employees = new List <Employee> {
                    new Employee()
                    {
                        Name = "Peter Gibbons", Age = 34
                    },
                    new Employee()
                    {
                        Name = "Michael Bolton", Age = 39
                    }
                }
            };

            // Act
            var result = SerializationHelper.Clone <Company>(graph, formatter);

            // Assert
            Assert.AreEqual("Initech Corporation", result.Name);
            Assert.IsNotNull(result.Employees);
            Assert.AreEqual(2, result.Employees.Count);
            Assert.AreEqual("Peter Gibbons", result.Employees.ElementAt(0).Name);
            Assert.AreEqual("Michael Bolton", result.Employees.ElementAt(1).Name);
        }
Exemplo n.º 2
0
            private ThreadInfo(bool propogateThreadPrincipal, bool propogateCallContext)
            {
                if (propogateThreadPrincipal)
                {
                    principal = Thread.CurrentPrincipal;
                }

                if (propogateCallContext && (miGetLogicalCallContext != null))
                {
                    callContext = (LogicalCallContext)miGetLogicalCallContext.Invoke(Thread.CurrentThread, null);
                    callContext = SerializationHelper.Clone <LogicalCallContext>(callContext);
                }
            }
        public void CanDeserializeType()
        {
            // Arrange
            var formatter = new ProtoBufFormatter();
            var graph     = new Employee(16)
            {
                Name = "Kalle", Age = 42
            };

            // Act
            var result = SerializationHelper.Clone <Employee>(graph, formatter);

            // Assert
            Assert.IsInstanceOf <Employee>(result);
            Assert.AreEqual("Kalle", result.Name);
            Assert.AreEqual(42, result.Age);
            Assert.AreEqual(16, result.ShoeSize);
        }
Exemplo n.º 4
0
        public static LASVersionInfo Create(LASVersion version)
        {
            var versionInfo = new LASVersionInfo(version);

            return(SerializationHelper.Clone <LASVersionInfo>(versionInfo));
        }