private ChangedRelationShip <TKey> BuildChangeRelationshipTemplate(IChangeTrackable <TKey> parent, PropertyInfo propertyInfo)
        {
            OwnershipActions ownershipActions = null;
            var key = new Tuple <Type, PropertyInfo>(parent.GetType(), propertyInfo);

            _ownerMappings.TryGetValue(key, out ownershipActions);
            return(new ChangedRelationShip <TKey>(parent, propertyInfo, ownershipActions));
        }
        /// <summary>
        /// By adding an owner mapping you will be changing how elements get flagged.
        /// By being the owner the parent object in the tree can flag sub properties as added, removed or deleted
        /// </summary>
        public ChangeAssessor <TKey> AddOwnerMapping <T>(Expression <Func <T, object> > property, bool add = true, bool update = true, bool delete = true) where T : class
        {
            var propertyInfo = ResolvePropertyInfo <T>(property);
            OwnershipActions ownershipActions = null;
            var key = new Tuple <Type, PropertyInfo>(typeof(T), propertyInfo);

            if (!_ownerMappings.TryGetValue(key, out ownershipActions))
            {
                ownershipActions = new OwnershipActions()
                {
                    Add    = add,
                    Delete = delete,
                    Update = update
                };
                _ownerMappings.Add(key, ownershipActions);
            }
            return(this);
        }
Пример #3
0
 public ChangedRelationShip(IChangeTrackable <TKey> parent, PropertyInfo property, OwnershipActions ownershipActions)
 {
     Parent           = parent;
     Property         = property;
     OwnershipActions = ownershipActions ?? new OwnershipActions();
 }