Example #1
0
        public void Update(object entity, IEntityProperty[] activeProperties)
        {
            if (_entity == null)
            {
                _entity = entity;
                for (int i = 0; i < activeProperties.Length; i++)
                {
                    _properties.Add(activeProperties[i], null);
                }
            }
            else
            {
                for (int i = 0; i < activeProperties.Length; i++)
                {
                    object          nothing;
                    IEntityProperty property = activeProperties[i];

                    // Update the property value
                    property.SetValue(_entity, property.GetValue(entity));

                    if (!_properties.TryGetValue(property, out nothing))
                    {
                        _properties.Add(property, null);
                    }
                }
            }

            TimeUpdated = DateTime.Now;
        }
Example #2
0
        /*=========================*/
        #endregion

        #region Public Methods
        /*=========================*/

        public bool IsActive(Entity parent)
        {
            if (parent.GetType() != ParentProperty.EntityType && !parent.GetType().IsSubclassOf(parent.GetType()))
            {
                throw new ArgumentException("Parent entity must be of same type as property's parent type", "parent");
            }

            if (!ParentProperty.IsAvailable(parent))
            {
                return(false);
            }

            bool contains = AcceptedValues.Contains(ParentProperty.GetValue(parent));

            return
                ((InclusionType == DependencyInclusionType.Inclusive && contains) ||
                 (InclusionType == DependencyInclusionType.Exclusive && !contains));
        }