Ejemplo n.º 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?>();
        }
Ejemplo n.º 2
0
        private object[] _deserializedData; // only used for deserialization

        public DataManager(
            ClientTransaction clientTransaction,
            IClientTransactionEventSink transactionEventSink,
            IDataContainerEventListener dataContainerEventListener,
            IInvalidDomainObjectManager invalidDomainObjectManager,
            IObjectLoader objectLoader,
            IRelationEndPointManager relationEndPointManager)
        {
            ArgumentUtility.CheckNotNull("clientTransaction", clientTransaction);
            ArgumentUtility.CheckNotNull("transactionEventSink", transactionEventSink);
            ArgumentUtility.CheckNotNull("dataContainerEventListener", dataContainerEventListener);
            ArgumentUtility.CheckNotNull("invalidDomainObjectManager", invalidDomainObjectManager);
            ArgumentUtility.CheckNotNull("objectLoader", objectLoader);
            ArgumentUtility.CheckNotNull("relationEndPointManager", relationEndPointManager);

            _clientTransaction          = clientTransaction;
            _transactionEventSink       = transactionEventSink;
            _dataContainerEventListener = dataContainerEventListener;
            _invalidDomainObjectManager = invalidDomainObjectManager;
            _objectLoader            = objectLoader;
            _relationEndPointManager = relationEndPointManager;

            _dataContainerMap       = new DataContainerMap(_transactionEventSink);
            _domainObjectStateCache = new DomainObjectStateCache(clientTransaction);
        }
Ejemplo n.º 3
0
        public void SetEventListener(IDataContainerEventListener listener)
        {
            ArgumentUtility.CheckNotNull("listener", listener);

            if (_eventListener != null)
            {
                throw new InvalidOperationException("Only one event listener can be registered for a DataContainer.");
            }
            _eventListener = listener;
        }
Ejemplo n.º 4
0
        public void Discard()
        {
            CheckNotDiscarded();

            _isDiscarded = true;
            RaiseStateUpdatedNotification(StateType.Invalid);

            _clientTransaction = null;
            _eventListener     = null;
        }
Ejemplo n.º 5
0
        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();
        }