Beispiel #1
0
        /*=========================*/
        #endregion

        #region Constructors
        /*=========================*/

        /// <summary>
        ///
        /// </summary>
        /// <param name="parentProperty"></param>
        /// <param name="inclusionType"></param>
        /// <param name="acceptedValues"></param>
        internal Dependency(IEntityProperty parentProperty, DependencyInclusionType inclusionType, object[] acceptedValues)
        {
            InclusionType       = inclusionType;
            ParentProperty      = parentProperty;
            AcceptedValues      = new List <object>(acceptedValues);
            ValueChangedHandler = new EventHandler <ValueChangedEventArgs>(ParentValueChanged);
        }
Beispiel #2
0
        /*=========================*/
        #endregion

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

        /// <summary>
        ///
        /// </summary>
        /// <param name="property"></param>
        /// <param name="inclusionType"></param>
        /// <param name="acceptedValues"></param>
        /// <returns></returns>
        public Dependency Add(IEntityProperty property, DependencyInclusionType inclusionType, object[] acceptedValues)
        {
            if (_dependencies.ContainsKey(property))
            {
                throw new ArgumentException(String.Format("A dependency already exists on property {0}.", property.InlineName), "property");
            }

            // Circular dependency check
            if (property.GetParentDependency(_dependentProperty) != null)
            {
                throw new DependencyException(String.Format("Cannot add a dependency on {0} because it is in itself dependent on the current property {1}.", property.InlineName, _dependentProperty.InlineName));
            }

            Dependency newDep = new Dependency(property, inclusionType, acceptedValues);

            _dependencies.Add(property, newDep);
            property.ValueChanged += newDep.ParentValueChanged;

            return(newDep);
        }