// 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?>();
        }
        // construction and disposing

        private DataContainer(ObjectID id, DataContainerStateType state, object timestamp, Dictionary <PropertyDefinition, PropertyValue> propertyValues)
        {
            ArgumentUtility.CheckNotNull("id", id);
            ArgumentUtility.CheckNotNull("propertyValues", propertyValues);

            _id        = id;
            _timestamp = timestamp;
            _state     = state;

            _propertyValues = propertyValues;
        }
        public void Delete()
        {
            CheckNotDiscarded();

            if (_state == DataContainerStateType.New)
            {
                throw new InvalidOperationException("New data containers cannot be deleted, they have to be discarded.");
            }

            _state = DataContainerStateType.Deleted;
            RaiseStateUpdatedNotification(StateType.Deleted);
        }
        public void RollbackState()
        {
            CheckNotDiscarded();

            if (_state == DataContainerStateType.New)
            {
                throw new InvalidOperationException("New data containers cannot be rolled back, they have to be discarded.");
            }

            foreach (PropertyValue propertyValue in _propertyValues.Values)
            {
                propertyValue.RollbackState();
            }

            _hasBeenMarkedChanged = false;
            _hasBeenChanged       = false;
            _state = DataContainerStateType.Existing;
            RaiseStateUpdatedNotification(StateType.Unchanged);
        }