Example #1
0
        public static void SetValue(object instance, MutableMember member, object value)
        {
            var perspexProperty = FindPerspexProperty(instance, member);

            if (value is IBinding)
            {
                SetBinding(instance, member, perspexProperty, (IBinding)value);
            }
            else if (perspexProperty != null)
            {
                ((PerspexObject)instance).SetValue(perspexProperty, value);
            }
            else if (instance is Setter && member.Name == "Value")
            {
                // TODO: Make this more generic somehow.
                var setter = (Setter)instance;
                var targetType = setter.Property.PropertyType;
                var valuePipeline = new ValuePipeline(member.TypeRepository, null);
                var xamlType = member.TypeRepository.GetByType(targetType);
                SetClrProperty(instance, member, valuePipeline.ConvertValueIfNecessary(value, xamlType));
            }
            else
            {
                SetClrProperty(instance, member, value);
            }
        }
Example #2
0
        public void AssignChildToParentProperty()
        {
            var previousMember = (MutableXamlMember)Previous.XamlMember;

            var compatibleValue = ValuePipeline.ConvertValueIfNecessary(Current.Instance, previousMember.XamlType);

            previousMember.SetValue(Previous.Instance, compatibleValue);
        }
Example #3
0
        public StateCommuter(StackingLinkedList<Level> stack, IWiringContext wiringContext, ITopDownValueContext topDownValueContext)
        {
            Guard.ThrowIfNull(stack, nameof(stack));
            Guard.ThrowIfNull(wiringContext, nameof(wiringContext));
            Guard.ThrowIfNull(topDownValueContext, nameof(topDownValueContext));

            Stack = stack;
            this.topDownValueContext = topDownValueContext;
            ValuePipeline = new ValuePipeline(wiringContext.TypeContext, topDownValueContext);
        }
Example #4
0
        public StateCommuter(StackingLinkedList <Level> stack, IWiringContext wiringContext, ITopDownValueContext topDownValueContext)
        {
            Guard.ThrowIfNull(stack, nameof(stack));
            Guard.ThrowIfNull(wiringContext, nameof(wiringContext));
            Guard.ThrowIfNull(topDownValueContext, nameof(topDownValueContext));

            Stack = stack;
            this.topDownValueContext = topDownValueContext;
            ValuePipeline            = new ValuePipeline(wiringContext.TypeContext, topDownValueContext);
            instanceProperties       = new InstanceProperties();
        }
Example #5
0
        public StateCommuter(StackingLinkedList<Level> stack,
            IRuntimeTypeSource typeSource,
            ITopDownValueContext topDownValueContext,
            IInstanceLifeCycleListener lifecycleListener)
        {
            Guard.ThrowIfNull(stack, nameof(stack));
            Guard.ThrowIfNull(typeSource, nameof(typeSource));
            Guard.ThrowIfNull(topDownValueContext, nameof(topDownValueContext));

            Stack = stack;
            this.topDownValueContext = topDownValueContext;
            this.lifecycleListener = lifecycleListener;
            ValuePipeline = new ValuePipeline(typeSource, topDownValueContext);
        }
 public override void SetValue(object instance, object value)
 {
     if (member.Name == "Value" && instance is Setter)
     {
         var setter = (Setter) instance;                
         var targetType = setter.Property.PropertyType;
         var valuePipeline = new ValuePipeline(member.TypeRepository, null);
         var xamlType = member.TypeRepository.GetByType(targetType);
         base.SetValue(instance, valuePipeline.ConvertValueIfNecessary(value, xamlType));
     }
     else
     {
         if (!TrySetDependencyProperty(instance, value))
         {
             base.SetValue(instance, value);
         }
     }
 }
 public override void SetValue(object instance, object value)
 {
     if (value is IBinding)
     {
         HandleBinding(instance, (IBinding)value);
     }
     else if (IsPerspexProperty)
     {
         HandlePerspexProperty(instance, value);
     }
     else if (instance is Setter && _xamlMember.Name == "Value")
     {
         var setter = (Setter)instance;
         var targetType = setter.Property.PropertyType;
         var valuePipeline = new ValuePipeline(_xamlMember.TypeRepository, null);
         var xamlType = _xamlMember.TypeRepository.GetXamlType(targetType);
         base.SetValue(instance, valuePipeline.ConvertValueIfNecessary(value, xamlType));
     }
     else
     {
         base.SetValue(instance, value);
     }
 }