// -------------------------------------------------------------------------------------------
        public TweenProperty(object target, string property)
        {
            _target      = target;
            _property    = property;
            _invalidated = false;
            PropertyMapper map = PropertyMapper.GetMap(property);
            Type           t   = target.GetType();

            _getter = map.GetGetter(t);
            _setter = map.GetSetter(t);
        }
Exemple #2
0
 /// <summary>
 /// Constructs a new instance.
 /// </summary>
 /// <param name="getParent">node parent getter delegate</param>
 /// <param name="getChildren">node children getter delegate</param>
 /// <param name="setChildren">node children setter delegate</param>
 /// <param name="getPreds">node predecessors getter delegate</param>
 /// <param name="setPreds">node predecessors setter delegate</param>
 /// <param name="getTempList">node temporary list storage getter delegate</param>
 /// <param name="setTempList">node temporary list storage getter delegate</param>
 /// <param name="getPreOrderIndex">node pre-order index getter delegate</param>
 /// <param name="setPreOrderIndex">node pre-order index setter delegate</param>
 /// <param name="getPreOrderLast">node pre-order last index getter delegate</param>
 /// <param name="setPreOrderLast">node pre-order last index setter delegate</param>
 /// <param name="getPostOrderIndex">node post-order index getter delegate</param>
 /// <param name="setPostOrderIndex">node post-order index setter delegate</param>
 /// <param name="getType">node type getter delegate</param>
 /// <param name="setType">node type setter delegate</param>
 /// <param name="getBackPreds">node backPreds getter delegate</param>
 /// <param name="setBackPreds">node backPreds setter delegate</param>
 /// <param name="getNonBackPreds">node nonBackPreds getter delegate</param>
 /// <param name="setNonBackPreds">node nonBackPreds setter delegate</param>
 /// <param name="getRedBackIn">node redBackIn getter delegate</param>
 /// <param name="setRedBackIn">node redBackIn setter delegate</param>
 /// <param name="getOtherIn">node otherIn getter delegate</param>
 /// <param name="setOtherIn">node otherIn setter delegate</param>
 /// <param name="getHeader">node loop header getter delegate</param>
 /// <param name="setHeader">node loop header setter delegate</param>
 /// <param name="getIDom">node immediate dominator getter delegate</param>
 /// <param name="setIDom">node immediate dominator setter delegate</param>
 /// <param name="getIDoms">node immediate dominatees getter delegate</param>
 /// <param name="setIDoms">node immediate dominatees setter delegate</param>
 public DefaultTreeAdapter(GetterFunc <T, T> getParent,
                           GetterFunc <T, T[]> getChildren,
                           SetterFunc <T, T[]> setChildren,
                           GetterFunc <T, T[]> getPreds,
                           SetterFunc <T, T[]> setPreds,
                           GetterFunc <T, List <T> > getTempList,
                           SetterFunc <T, List <T> > setTempList,
                           GetterFunc <T, int> getPreOrderIndex,
                           SetterFunc <T, int> setPreOrderIndex,
                           GetterFunc <T, T> getPreOrderLast,
                           SetterFunc <T, T> setPreOrderLast,
                           GetterFunc <T, int> getPostOrderIndex,
                           SetterFunc <T, int> setPostOrderIndex,
                           GetterFunc <T, ENodeType> getType,
                           SetterFunc <T, ENodeType> setType,
                           GetterFunc <T, HashSet <T> > getBackPreds,
                           SetterFunc <T, HashSet <T> > setBackPreds,
                           GetterFunc <T, HashSet <T> > getNonBackPreds,
                           SetterFunc <T, HashSet <T> > setNonBackPreds,
                           GetterFunc <T, HashSet <T> > getRedBackIn,
                           SetterFunc <T, HashSet <T> > setRedBackIn,
                           GetterFunc <T, HashSet <T> > getOtherIn,
                           SetterFunc <T, HashSet <T> > setOtherIn,
                           GetterFunc <T, T> getHeader,
                           SetterFunc <T, T> setHeader,
                           GetterFunc <T, T> getIDom,
                           SetterFunc <T, T> setIDom,
                           GetterFunc <T, T[]> getIDoms,
                           SetterFunc <T, T[]> setIDoms
                           )
 {
     Parent         = new DelegatePropMap <T, T>(getParent);
     Succs          = new DelegatePropMap <T, T[]>(getChildren, setChildren);
     Preds          = new DelegatePropMap <T, T[]>(getPreds, setPreds);
     TempList       = new DelegatePropMap <T, List <T> >(getTempList, setTempList);
     PreOrderIndex  = new DelegatePropMap <T, int>(getPreOrderIndex, setPreOrderIndex);
     PreOrderLast   = new DelegatePropMap <T, T>(getPreOrderLast, setPreOrderLast);
     PostOrderIndex = new DelegatePropMap <T, int>(getPostOrderIndex, setPostOrderIndex);
     Type           = new DelegatePropMap <T, ENodeType>(getType, setType);
     BackPreds      = new DelegatePropMap <T, HashSet <T> >(getBackPreds, setBackPreds);
     NonBackPreds   = new DelegatePropMap <T, HashSet <T> >(getNonBackPreds, setNonBackPreds);
     RedBackIn      = new DelegatePropMap <T, HashSet <T> >(getRedBackIn, setRedBackIn);
     OtherIn        = new DelegatePropMap <T, HashSet <T> >(getOtherIn, setOtherIn);
     Header         = new DelegatePropMap <T, T>(getHeader, setHeader);
     IDom           = new DelegatePropMap <T, T>(getIDom, setIDom);
     IDoms          = new DelegatePropMap <T, T[]>(getIDoms, setIDoms);
 }
Exemple #3
0
        public static void ValidateAccessors <TProperty>(GetterFunc <TProperty> getter, SetterFunc <TProperty> setter)
        {
            if (getter == null)
            {
                throw new Exception("Attached Properties must have a getter!");
            }

            if (setter == null)
            {
                throw new Exception("Attached Properties must have a setter!");
            }

            string getterName = getter.GetMethodInfo().Name;
            string setterName = setter.GetMethodInfo().Name;

            if (!getterName.StartsWith("Get"))
            {
                throw new Exception("Getter Error: Attached properties require a getter formatted Get{name}.");
            }

            if (!setterName.StartsWith("Set"))
            {
                throw new Exception("Setter Error: Attached properties require a setter formatted Set{name}.");
            }

            if (getterName.Substring(3) != setterName.Substring(3))
            {
                throw new Exception("Attached properties require a getter and setter formatted Get{name}/Set{name} where the names match.");
            }
        }
Exemple #4
0
        /// <summary>
        /// Registers a readonly attached property with the dependency property system.
        /// </summary>
        /// <typeparam name="TProperty">The type of the attached property (inferred)</typeparam>
        /// <param name="ownerType">The attached property owner -- can't be inferred :'(</param>
        /// <param name="getter">The attached property's getter (verified for required verbiage and type).</param>
        /// <param name="setter">The attached property's setter (verified for required verbiage and type).</param>
        /// <param name="metadata">The property metadata to register for this attached property with the dependency property system.</param>
        /// <returns>The <see cref="DependencyProperty"/> that was registered for this attached property.</returns>
        public static DependencyPropertyKey RegisterReadOnly <TProperty>(Type ownerType, GetterFunc <TProperty> getter, SetterFunc <TProperty> setter, PropertyMetadata metadata)
        {
            ValidateAccessors(getter, setter);

            // Could use getter or setter, it's the same either way
            string name = getter.Method.Name.Substring(3);

            return(DependencyProperty.RegisterAttachedReadOnly(name, typeof(TProperty), ownerType, metadata));
        }
Exemple #5
0
 /// <summary>
 /// Registers a readonly attached property with the dependency property system.
 /// </summary>
 /// <typeparam name="TProperty">The type of the attached property (inferred)</typeparam>
 /// <param name="ownerType">The attached property owner -- can't be inferred :'(</param>
 /// <param name="getter">The attached property's getter (verified for required verbiage and type).</param>
 /// <param name="setter">The attached property's setter (verified for required verbiage and type).</param>
 /// <param name="defaultValue">The default value for the attached property.</param>
 /// <param name="propChanged">The property changed callback delegate.</param>
 /// <returns>The <see cref="DependencyProperty"/> that was registered for this attached property.</returns>
 public static DependencyPropertyKey RegisterReadOnly <TProperty>(Type ownerType, GetterFunc <TProperty> getter, SetterFunc <TProperty> setter, TProperty defaultValue, PropertyChangedCallback propChanged)
 {
     return(RegisterReadOnly(ownerType, getter, setter, new FrameworkPropertyMetadata(defaultValue, propChanged)));
 }
Exemple #6
0
        // ==============================================================================================================
        // ====             Registering *Readonly* Attached Properties                                              =====
        // ==============================================================================================================

#if !WINDOWS_UWP // Note: UWP does not support readonly dependency properties (for some reason?)
        /// <summary>
        /// Registers a readonly attached property with the dependency property system.
        /// Note the default value for this attached property will be default(<see cref="TProperty"/>)
        /// </summary>
        /// <typeparam name="TProperty">The type of the attached property (inferred)</typeparam>
        /// <param name="ownerType">The attached property owner -- can't be inferred :'(</param>
        /// <param name="getter">The attached property's getter (verified for required verbiage and type).</param>
        /// <param name="setter">The attached property's setter (verified for required verbiage and type).</param>
        /// <returns>The <see cref="DependencyProperty"/> that was registered for this attached property.</returns>
        public static DependencyPropertyKey RegisterReadOnly <TProperty>(Type ownerType, GetterFunc <TProperty> getter, SetterFunc <TProperty> setter)
        {
            return(RegisterReadOnly(ownerType, getter, setter, new FrameworkPropertyMetadata(default(TProperty))));
        }
Exemple #7
0
 /// <summary>
 /// Registers an attached property with the dependency property system.
 /// </summary>
 /// <typeparam name="TProperty">The type of the attached property (inferred)</typeparam>
 /// <param name="ownerType">The attached property owner -- can't be inferred :'(</param>
 /// <param name="getter">The attached property's getter (verified for required verbiage and type).</param>
 /// <param name="setter">The attached property's setter (verified for required verbiage and type).</param>
 /// <param name="defaultValue">The default value for the attached property.</param>
 /// <param name="propChanged">The property changed callback delegate.</param>
 /// <param name="coerceValue">The coerce value callback delegate.</param>
 /// <returns>The <see cref="DependencyProperty" /> that was registered for this attached property.</returns>
 public static DependencyProperty Register <TProperty>(Type ownerType, GetterFunc <TProperty> getter, SetterFunc <TProperty> setter, TProperty defaultValue, PropertyChangedCallback propChanged, CoerceValueCallback coerceValue)
 {
     return(Register(ownerType, getter, setter, new FrameworkPropertyMetadata(defaultValue, propChanged, coerceValue)));
 }
Exemple #8
0
 /// <summary>
 /// Registers an attached property with the dependency property system.
 /// Note the default value for this attached property will be default(<see cref="TProperty"/>)
 /// </summary>
 /// <typeparam name="TProperty">The type of the attached property (inferred)</typeparam>
 /// <param name="ownerType">The attached property owner -- can't be inferred :'(</param>
 /// <param name="getter">The attached property's getter (verified for required verbiage and type).</param>
 /// <param name="setter">The attached property's setter (verified for required verbiage and type).</param>
 /// <param name="propChanged">The property changed callback delegate.</param>
 /// <returns>The <see cref="DependencyProperty"/> that was registered for this attached property.</returns>
 public static DependencyProperty Register <TProperty>(Type ownerType, GetterFunc <TProperty> getter, SetterFunc <TProperty> setter, PropertyChangedCallback propChanged)
 {
     return(Register(ownerType, getter, setter, new PropertyMetadata(default(TProperty), propChanged)));
 }
Exemple #9
0
 /// <summary>
 /// Registers an attached property with the dependency property system.
 /// </summary>
 /// <typeparam name="TProperty">The type of the attached property (inferred)</typeparam>
 /// <param name="ownerType">The attached property owner -- can't be inferred :'(</param>
 /// <param name="getter">The attached property's getter (verified for required verbiage and type).</param>
 /// <param name="setter">The attached property's setter (verified for required verbiage and type).</param>
 /// <param name="defaultValue">The default value for the attached property.</param>
 /// <returns>The <see cref="DependencyProperty"/> that was registered for this attached property.</returns>
 public static DependencyProperty Register <TProperty>(Type ownerType, GetterFunc <TProperty> getter, SetterFunc <TProperty> setter, TProperty defaultValue)
 {
     return(Register(ownerType, getter, setter, new PropertyMetadata(defaultValue)));
 }
Exemple #10
0
 /// <summary>
 /// Constructs a new instance capable of writing property values.
 /// </summary>
 /// <param name="set">property setter delegate</param>
 public DelegatePropMap(SetterFunc <TThis, TValue> set)
 {
     _set = set;
 }
Exemple #11
0
 /// <summary>
 /// Constructs a new instance capable of reading and writing property values.
 /// </summary>
 /// <param name="get">property getter delegate</param>
 /// <param name="set">property setter delegate</param>
 public DelegatePropMap(GetterFunc <TThis, TValue> get, SetterFunc <TThis, TValue> set)
 {
     _get = get;
     _set = set;
 }