コード例 #1
0
        // ReSharper disable UnusedMember.Local
        private DataContainer(FlattenedDeserializationInfo info)
        {
            ArgumentUtility.CheckNotNull("info", info);

            _id          = info.GetValueForHandle <ObjectID> ();
            _timestamp   = info.GetValue <object>();
            _isDiscarded = info.GetBoolValue();

            _propertyValues = new Dictionary <PropertyDefinition, PropertyValue>();

            if (!_isDiscarded)
            {
                for (int i = 0; i < ClassDefinition.GetPropertyDefinitions().Count(); ++i)
                {
                    var propertyName       = info.GetValueForHandle <string>();
                    var propertyDefinition = ClassDefinition.GetPropertyDefinition(propertyName);
                    var propertyValue      = new PropertyValue(propertyDefinition, propertyDefinition.DefaultValue);
                    propertyValue.DeserializeFromFlatStructure(info);
                    _propertyValues.Add(propertyDefinition, propertyValue);
                }
            }

            _clientTransaction    = info.GetValueForHandle <ClientTransaction> ();
            _eventListener        = info.GetValueForHandle <IDataContainerEventListener> ();
            _state                = (DataContainerStateType)info.GetIntValue();
            _domainObject         = info.GetValueForHandle <DomainObject> ();
            _hasBeenMarkedChanged = info.GetBoolValue();
            _hasBeenChanged       = info.GetValue <bool?>();
        }
コード例 #2
0
        public void FlattenedSerializableHandles_RecursiveHandles()
        {
            FlattenedSerializableStub stub1 = new FlattenedSerializableStub("begone, foul fiend", 123);
            FlattenedSerializableStub stub2 = new FlattenedSerializableStub("befoul, gone fiend", 125);

            stub1.Data3 = stub2;
            stub2.Data3 = stub1;

            FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo();

            serializationInfo.AddHandle(stub1);
            object[] data = serializationInfo.GetData();

            FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data);

            deserializationInfo.GetValueForHandle <FlattenedSerializableStub> ();
            // The following would be expected if this worked
            //FlattenedSerializableStub deserializedStub1 = deserializationInfo.GetValueForHandle<FlattenedSerializableStub> ();
            //FlattenedSerializableStub deserializedStub2 = deserializedStub1.Data3;

            //Assert.AreNotSame (deserializedStub1, deserializedStub2);
            //Assert.AreEqual ("begone, foul fiend", deserializedStub1.Data1);
            //Assert.AreEqual (123, deserializedStub1.Data2);
            //Assert.AreSame (deserializedStub2, deserializedStub1.Data3);

            //Assert.AreEqual ("befoul, gone fiend", deserializedStub2.Data1);
            //Assert.AreEqual (125, deserializedStub2.Data2);
            //Assert.AreSame (deserializedStub1, deserializedStub2.Data3);
        }
コード例 #3
0
        public void SignalDeserializationFinished()
        {
            var serializationInfo = new FlattenedSerializationInfo();

            serializationInfo.AddValue(1);
            serializationInfo.AddValue(2);
            serializationInfo.AddValue("three");

            bool   deserializationFinishedCalled = false;
            object deserializationFinishedSender = null;

            var deserializationInfo = new FlattenedDeserializationInfo(serializationInfo.GetData());

            deserializationInfo.DeserializationFinished += (sender, args) => { deserializationFinishedCalled = true; deserializationFinishedSender = sender; };

            var o = deserializationInfo.GetValue <object> ();

            Assert.That(o, Is.EqualTo(1));

            o = deserializationInfo.GetValue <object> ();
            Assert.That(o, Is.EqualTo(2));

            o = deserializationInfo.GetValue <object> ();
            Assert.That(o, Is.EqualTo("three"));
            Assert.That(deserializationFinishedCalled, Is.False);

            deserializationInfo.SignalDeserializationFinished();

            Assert.That(deserializationFinishedCalled, Is.True);
            Assert.That(deserializationFinishedSender, Is.SameAs(deserializationInfo));
        }
コード例 #4
0
        public SynchronizedRealObjectEndPointSyncState(FlattenedDeserializationInfo info)
        {
            ArgumentUtility.CheckNotNull("info", info);

            _endPointProvider     = info.GetValueForHandle <IRelationEndPointProvider>();
            _transactionEventSink = info.GetValueForHandle <IClientTransactionEventSink>();
        }
コード例 #5
0
        public void Handles()
        {
            DateTime dt1 = DateTime.MinValue;
            DateTime dt2 = DateTime.MaxValue;

            string s1 = "Foo";
            string s2 = "Fox";

            FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo();

            serializationInfo.AddHandle(dt1);
            serializationInfo.AddHandle(dt2);
            serializationInfo.AddHandle(dt1);
            serializationInfo.AddHandle(dt1);
            serializationInfo.AddHandle(s1);
            serializationInfo.AddHandle(s2);
            serializationInfo.AddHandle(s1);
            serializationInfo.AddHandle(s1);
            serializationInfo.AddHandle(s2);

            object[] data = serializationInfo.GetData();

            FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data);

            Assert.That(deserializationInfo.GetValueForHandle <DateTime> (), Is.EqualTo(dt1));
            Assert.That(deserializationInfo.GetValueForHandle <DateTime> (), Is.EqualTo(dt2));
            Assert.That(deserializationInfo.GetValueForHandle <DateTime> (), Is.EqualTo(dt1));
            Assert.That(deserializationInfo.GetValueForHandle <DateTime> (), Is.EqualTo(dt1));
            Assert.That(deserializationInfo.GetValueForHandle <string> (), Is.EqualTo(s1));
            Assert.That(deserializationInfo.GetValueForHandle <string> (), Is.EqualTo(s2));
            Assert.That(deserializationInfo.GetValueForHandle <string> (), Is.EqualTo(s1));
            Assert.That(deserializationInfo.GetValueForHandle <string> (), Is.EqualTo(s1));
            Assert.That(deserializationInfo.GetValueForHandle <string> (), Is.EqualTo(s2));
        }
コード例 #6
0
        public void FlattenedSerializableHandles_WithOtherHandles()
        {
            FlattenedSerializableStub stub1 = new FlattenedSerializableStub("begone, foul fiend", 123);
            FlattenedSerializableStub stub2 = new FlattenedSerializableStub("befoul, gone fiend", 125);

            stub1.Data3 = stub2;

            FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo();

            serializationInfo.AddHandle(stub1);
            object[] data = serializationInfo.GetData();

            FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data);
            FlattenedSerializableStub    deserializedStub1   = deserializationInfo.GetValueForHandle <FlattenedSerializableStub> ();
            FlattenedSerializableStub    deserializedStub2   = deserializedStub1.Data3;

            Assert.That(deserializedStub2, Is.Not.SameAs(deserializedStub1));
            Assert.That(deserializedStub1.Data1, Is.EqualTo("begone, foul fiend"));
            Assert.That(deserializedStub1.Data2, Is.EqualTo(123));
            Assert.That(deserializedStub1.Data3, Is.SameAs(deserializedStub2));

            Assert.That(deserializedStub2.Data1, Is.EqualTo("befoul, gone fiend"));
            Assert.That(deserializedStub2.Data2, Is.EqualTo(125));
            Assert.That(deserializedStub2.Data3, Is.Null);
        }
コード例 #7
0
        public static T Deserialize <T> (object[] data) where T : IFlattenedSerializable
        {
            FlattenedDeserializationInfo info = new FlattenedDeserializationInfo(data);
            var value = info.GetValue <T>();

            info.SignalDeserializationFinished();
            return(value);
        }
コード例 #8
0
 protected RealObjectEndPoint(FlattenedDeserializationInfo info)
     : base(info)
 {
     _foreignKeyDataContainer = info.GetValueForHandle <DataContainer> ();
     _propertyDefinition      = GetPropertyDefinition();
     _endPointProvider        = info.GetValueForHandle <IRelationEndPointProvider> ();
     _transactionEventSink    = info.GetValueForHandle <IClientTransactionEventSink> ();
     _syncState = info.GetValueForHandle <IRealObjectEndPointSyncState> ();
 }
コード例 #9
0
        public void SignalDeserializationFinished_BeforeObjectStreamFinished()
        {
            var serializationInfo = new FlattenedSerializationInfo();

            serializationInfo.AddValue(DateTime.Now);

            var deserializationInfo = new FlattenedDeserializationInfo(serializationInfo.GetData());

            deserializationInfo.SignalDeserializationFinished();
        }
コード例 #10
0
        public void InvalidNumberOfDeserializedItems()
        {
            FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo();

            object[] data = serializationInfo.GetData();

            FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data);

            deserializationInfo.GetValue <string> ();
        }
コード例 #11
0
        protected RelationEndPointMap(FlattenedDeserializationInfo info)
            : this(info.GetValueForHandle <IClientTransactionEventSink>())
        {
            var endPointArray = info.GetArray <IRelationEndPoint> ();

            foreach (IRelationEndPoint endPoint in endPointArray)
            {
                _relationEndPoints.Add(endPoint.ID, endPoint);
            }
        }
コード例 #12
0
        public void SignalDeserializationFinished_BeforeBoolStreamFinished()
        {
            var serializationInfo = new FlattenedSerializationInfo();

            serializationInfo.AddBoolValue(true);

            var deserializationInfo = new FlattenedDeserializationInfo(serializationInfo.GetData());

            deserializationInfo.SignalDeserializationFinished();
        }
コード例 #13
0
        protected DataContainerMap(FlattenedDeserializationInfo info)
            : this(info.GetValueForHandle <IClientTransactionEventSink>())
        {
            var dataContainerCount = info.GetValue <int>();

            for (int i = 0; i < dataContainerCount; ++i)
            {
                _dataContainers.Add(info.GetValueForHandle <DataContainer>());
            }
        }
コード例 #14
0
        public VirtualObjectEndPointDataManager(FlattenedDeserializationInfo info)
        {
            ArgumentUtility.CheckNotNull("info", info);

            _endPointID = info.GetValueForHandle <RelationEndPointID>();
            _originalOppositeEndPoint = info.GetValue <IRealObjectEndPoint>();
            _originalOppositeObject   = info.GetValueForHandle <DomainObject>();
            _currentOppositeEndPoint  = info.GetValue <IRealObjectEndPoint>();
            _currentOppositeObject    = info.GetValueForHandle <DomainObject> ();
        }
コード例 #15
0
        protected IncompleteVirtualEndPointLoadStateBase(FlattenedDeserializationInfo info)
        {
            ArgumentUtility.CheckNotNull("info", info);
            _endPointLoader = info.GetValue <IEndPointLoader> ();

            var realObjectEndPoints = new List <IRealObjectEndPoint>();

            info.FillCollection(realObjectEndPoints);
            _originalOppositeEndPoints = realObjectEndPoints.ToDictionary(ep => ep.ObjectID);
        }
コード例 #16
0
        protected VirtualObjectEndPoint(FlattenedDeserializationInfo info)
            : base(info)
        {
            _lazyLoader           = info.GetValueForHandle <ILazyLoader> ();
            _endPointProvider     = info.GetValueForHandle <IRelationEndPointProvider> ();
            _transactionEventSink = info.GetValueForHandle <IClientTransactionEventSink> ();
            _dataManagerFactory   = info.GetValueForHandle <IVirtualObjectEndPointDataManagerFactory> ();

            _loadState      = info.GetValue <IVirtualObjectEndPointLoadState> ();
            _hasBeenTouched = info.GetBoolValue();
        }
コード例 #17
0
        public void InvalidDeserializedType_WithNullAndValueType()
        {
            FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo();

            serializationInfo.AddValue <object> (null);
            object[] data = serializationInfo.GetData();

            FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data);

            deserializationInfo.GetValue <DateTime> ();
        }
コード例 #18
0
        public void InvalidDeserializedType_DifferentStream()
        {
            FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo();

            serializationInfo.AddIntValue(1);
            object[] data = serializationInfo.GetData();

            FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data);

            deserializationInfo.GetValue <string> ();
        }
コード例 #19
0
        public void InvalidDeserializedType()
        {
            FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo();

            serializationInfo.AddValue(DateTime.Now);
            object[] data = serializationInfo.GetData();

            FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data);

            deserializationInfo.GetValue <string> ();
        }
コード例 #20
0
        public void MissingDeserializationCtor()
        {
            FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo();

            serializationInfo.AddValue(new FlattenedSerializableWithoutCtorStub());
            object[] data = serializationInfo.GetData();

            FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data);

            deserializationInfo.GetValue <FlattenedSerializableWithoutCtorStub>();
        }
コード例 #21
0
        protected CompleteVirtualEndPointLoadStateBase(FlattenedDeserializationInfo info)
        {
            ArgumentUtility.CheckNotNull("info", info);

            _dataManager          = info.GetValueForHandle <TDataManager> ();
            _endPointProvider     = info.GetValueForHandle <IRelationEndPointProvider> ();
            _transactionEventSink = info.GetValueForHandle <IClientTransactionEventSink> ();
            var unsynchronizedOppositeEndPoints = new List <IRealObjectEndPoint> ();

            info.FillCollection(unsynchronizedOppositeEndPoints);
            _unsynchronizedOppositeEndPoints = unsynchronizedOppositeEndPoints.ToDictionary(ep => ep.ObjectID);
        }
コード例 #22
0
        protected RelationEndPointManager(FlattenedDeserializationInfo info)
        {
            ArgumentUtility.CheckNotNull("info", info);

            _clientTransaction = info.GetValueForHandle <ClientTransaction>();
            _lazyLoader        = info.GetValueForHandle <ILazyLoader>();
            _endPointFactory   = info.GetValueForHandle <IRelationEndPointFactory>();
            _registrationAgent = info.GetValueForHandle <IRelationEndPointRegistrationAgent> ();
            _map = info.GetValue <RelationEndPointMap> ();

            _dataContainerEndPointsRegistrationAgent = new DelegatingDataContainerEndPointsRegistrationAgent(_endPointFactory, _registrationAgent);
        }
コード例 #23
0
        public void FlattenedSerializables_Null()
        {
            FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo();

            serializationInfo.AddValue <FlattenedSerializableStub> (null);
            object[] data = serializationInfo.GetData();

            FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data);
            FlattenedSerializableStub    deserializedStub    = deserializationInfo.GetValue <FlattenedSerializableStub> ();

            Assert.That(deserializedStub, Is.Null);
        }
コード例 #24
0
        // ReSharper disable UnusedMember.Local
        private RelationEndPointID(FlattenedDeserializationInfo info)
        {
            var classDefinitionID = info.GetValueForHandle <string> ();
            var propertyName      = info.GetValueForHandle <string> ();
            var objectID          = info.GetValueForHandle <ObjectID> ();

            var classDefinition            = MappingConfiguration.Current.GetClassDefinition(classDefinitionID);
            var relationEndPointDefinition = classDefinition.GetMandatoryRelationEndPointDefinition(propertyName);

            _objectID   = objectID;
            _definition = relationEndPointDefinition;
        }
コード例 #25
0
 internal void DeserializeFromFlatStructure(FlattenedDeserializationInfo info)
 {
     _hasBeenTouched = info.GetBoolValue();
     _value          = info.GetValue <object> ();
     if (_hasBeenTouched)
     {
         _originalValue = info.GetValue <object> ();
     }
     else
     {
         _originalValue = _value;
     }
 }
コード例 #26
0
        public void InvalidArrayType()
        {
            object[] array1 = new object[] { "Foo", 1, 3.0 };

            FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo();

            serializationInfo.AddArray(array1);
            object[] data = serializationInfo.GetData();

            FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data);

            deserializationInfo.GetArray <int> ();
        }
コード例 #27
0
        public void InvalidCollectionType()
        {
            List <object> list = new List <object> (new object[] { "Foo", 1, 3.0 });

            FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo();

            serializationInfo.AddCollection(list);
            object[] data = serializationInfo.GetData();

            List <int> deserializedList1 = new List <int> ();
            FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data);

            deserializationInfo.FillCollection(deserializedList1);
        }
コード例 #28
0
        public void NullHandles()
        {
            FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo();

            serializationInfo.AddHandle <string> (null);
            serializationInfo.AddHandle <int?> (null);

            object[] data = serializationInfo.GetData();

            FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data);

            Assert.That(deserializationInfo.GetValueForHandle <string> (), Is.EqualTo(null));
            Assert.That(deserializationInfo.GetValueForHandle <int?> (), Is.EqualTo(null));
        }
コード例 #29
0
        public void FlattenedSerializables()
        {
            FlattenedSerializableStub  stub = new FlattenedSerializableStub("begone, foul fiend", 123);
            FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo();

            serializationInfo.AddValue(stub);
            object[] data = serializationInfo.GetData();

            FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data);
            FlattenedSerializableStub    deserializedStub    = deserializationInfo.GetValue <FlattenedSerializableStub> ();

            Assert.That(deserializedStub.Data1, Is.EqualTo("begone, foul fiend"));
            Assert.That(deserializedStub.Data2, Is.EqualTo(123));
        }
コード例 #30
0
        public void HandlesWithInvalidType()
        {
            DateTime dt1 = DateTime.MinValue;

            FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo();

            serializationInfo.AddHandle(dt1);
            serializationInfo.AddHandle(dt1);

            object[] data = serializationInfo.GetData();

            FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data);

            deserializationInfo.GetValueForHandle <DateTime> ();
            deserializationInfo.GetValueForHandle <string> ();
        }