Ejemplo n.º 1
0
 public void RuntimeInitializeInstance()
 {
     if (PropertyFactory == null)
     {
         PropertyFactory = new ConcreteDependencyPropertyFactory(_instance.GetType());
     }
 }
        public override TValue Coerce(object context, TValue value)
        {
            // Initialize property getters the first time.
            if (Factory == null)
            {
                // Get the dependency property factory.
                Type       controlType     = context.GetType();
                MemberInfo propertyFactory = controlType.GetMembers(typeof(DependencyPropertyFactory <TEnum>)).FirstOrDefault();

                if (propertyFactory == null)
                {
                    throw new InvalidImplementationException("No dependency property factory found in type: \"" + controlType + "\"");
                }

                Factory = (DependencyPropertyFactory <TEnum>)context.GetValue(propertyFactory);
            }

            // Pass the value of each dependent property.
            var dependentValues = EnumHelper <TEnum> .GetFlaggedValues(DependentProperties)
                                  .ToDictionary(p => p, p => Factory.GetValue(context as DependencyObject, p));

            return(Coerce(dependentValues, value));
        }
        public void OnSetValue(LocationInterceptionArgs args)
        {
            DependencyPropertyFactory <T> factory = WpfControlAspect <T> .PropertyFactories[_instance.GetType()];

            factory.SetValue(args.Instance as DependencyObject, _property, args.Value);
        }