// 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?>(); }
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)); }
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> (); }
internal void DeserializeFromFlatStructure(FlattenedDeserializationInfo info) { _hasBeenTouched = info.GetBoolValue(); _value = info.GetValue <object> (); if (_hasBeenTouched) { _originalValue = info.GetValue <object> (); } else { _originalValue = _value; } }
void IDeserializationCallback.OnDeserialization(object sender) { var doInfo = new FlattenedDeserializationInfo(_deserializedData); _clientTransaction = doInfo.GetValueForHandle <ClientTransaction> (); _transactionEventSink = doInfo.GetValueForHandle <IClientTransactionEventSink> (); _dataContainerEventListener = doInfo.GetValueForHandle <IDataContainerEventListener> (); _dataContainerMap = doInfo.GetValue <DataContainerMap>(); _relationEndPointManager = doInfo.GetValueForHandle <RelationEndPointManager>(); _domainObjectStateCache = doInfo.GetValue <DomainObjectStateCache>(); _invalidDomainObjectManager = doInfo.GetValue <IInvalidDomainObjectManager> (); _objectLoader = doInfo.GetValueForHandle <IObjectLoader>(); _deserializedData = null; doInfo.SignalDeserializationFinished(); }
public static T Deserialize <T> (object[] data) where T : IFlattenedSerializable { FlattenedDeserializationInfo info = new FlattenedDeserializationInfo(data); var value = info.GetValue <T>(); info.SignalDeserializationFinished(); return(value); }
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); }
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>()); } }
public void InvalidNumberOfDeserializedItems() { FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo(); object[] data = serializationInfo.GetData(); FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data); deserializationInfo.GetValue <string> (); }
public void InvalidDeserializedType_DifferentStream() { FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo(); serializationInfo.AddIntValue(1); object[] data = serializationInfo.GetData(); FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data); deserializationInfo.GetValue <string> (); }
public void InvalidDeserializedType() { FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo(); serializationInfo.AddValue(DateTime.Now); object[] data = serializationInfo.GetData(); FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data); deserializationInfo.GetValue <string> (); }
public void MissingDeserializationCtor() { FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo(); serializationInfo.AddValue(new FlattenedSerializableWithoutCtorStub()); object[] data = serializationInfo.GetData(); FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data); deserializationInfo.GetValue <FlattenedSerializableWithoutCtorStub>(); }
public void InvalidDeserializedType_WithNullAndValueType() { FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo(); serializationInfo.AddValue <object> (null); object[] data = serializationInfo.GetData(); FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data); deserializationInfo.GetValue <DateTime> (); }
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(); }
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); }
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); }
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)); }
public void Values() { FlattenedSerializationInfo serializationInfo = new FlattenedSerializationInfo(); serializationInfo.AddIntValue(1); serializationInfo.AddBoolValue(true); serializationInfo.AddIntValue(2); serializationInfo.AddBoolValue(false); serializationInfo.AddValue(new DateTime(2007, 1, 2)); serializationInfo.AddValue("Foo"); serializationInfo.AddValue <object> (null); serializationInfo.AddValue <int?> (null); object[] data = serializationInfo.GetData(); FlattenedDeserializationInfo deserializationInfo = new FlattenedDeserializationInfo(data); Assert.That(deserializationInfo.GetIntValue(), Is.EqualTo(1)); Assert.That(deserializationInfo.GetBoolValue(), Is.EqualTo(true)); Assert.That(deserializationInfo.GetIntValue(), Is.EqualTo(2)); Assert.That(deserializationInfo.GetBoolValue(), Is.EqualTo(false)); Assert.That(deserializationInfo.GetValue <DateTime> (), Is.EqualTo(new DateTime(2007, 1, 2))); Assert.That(deserializationInfo.GetValue <string> (), Is.EqualTo("Foo")); Assert.That(deserializationInfo.GetValue <int?> (), Is.EqualTo(null)); }
// ReSharper disable UnusedMember.Local private CollectionEndPointDataManager(FlattenedDeserializationInfo info) { ArgumentUtility.CheckNotNull("info", info); _endPointID = info.GetValueForHandle <RelationEndPointID>(); _changeDetectionStrategy = info.GetValueForHandle <ICollectionEndPointChangeDetectionStrategy>(); _changeCachingCollectionData = info.GetValue <ChangeCachingCollectionDataDecorator>(); _originalOppositeEndPoints = new HashSet <IRealObjectEndPoint>(); info.FillCollection(_originalOppositeEndPoints); _originalItemsWithoutEndPoint = new HashSet <DomainObject>(); info.FillCollection(_originalItemsWithoutEndPoint); var currentOppositeEndPoints = new List <IRealObjectEndPoint>(); info.FillCollection(currentOppositeEndPoints); _currentOppositeEndPoints = currentOppositeEndPoints.ToDictionary(ep => ep.ObjectID); }
public StateUpdateRaisingCollectionEndPointDecorator (FlattenedDeserializationInfo info) { _innerEndPoint = info.GetValue<ICollectionEndPoint>(); _listener = info.GetValueForHandle<IVirtualEndPointStateUpdateListener>(); }
protected RelationEndPoint(FlattenedDeserializationInfo info) { _clientTransaction = info.GetValueForHandle <ClientTransaction>(); _id = info.GetValue <RelationEndPointID>(); }
protected FlattenedSerializableStub(FlattenedDeserializationInfo info) { Data1 = info.GetValue <string> (); Data2 = info.GetIntValue(); Data3 = info.GetValueForHandle <FlattenedSerializableStub> (); }
public SerializableRealObjectEndPointFake(FlattenedDeserializationInfo info) { _owningObject = info.GetValue <DomainObject>(); _id = info.GetValue <RelationEndPointID>(); }