Пример #1
0
        public Action <T> GetSetter <T>(SetterContext ctx)
        {
            var setter = _knownSetterProvider
                         .MaybeFirst(p => p.Match(ctx))
                         .MustHaveValue(new NotSupportedException("Could not resolve a way to set {0} to target ({1}:{2})".Fmt(ctx.Value.GetType().Name, ctx.PropertyName, ctx.PropertyType.Name)));

            return(setter.Setter <T>(ctx));
        }
Пример #2
0
 public Action <T> Setter <T>(SetterContext ctx)
 {
     return(xaml =>
     {
         var list = xaml.GetValue <IList>(ctx.PropertyName);
         var values = (object[])ctx.Value;
         values.ForEach(v => list.Add(v));
     });
 }
Пример #3
0
        public Action <T> Setter <T>(SetterContext ctx)
        {
            var v = (StaticResource)ctx.Value;

            return(xaml => (xaml as FrameworkElement)
                   .Maybe(m => m.Get(f => f.TryFindResource(v.Key))
                          .Do(obj => xaml.SetValue(ctx.PropertyName, obj)),
                          m => m.Get(f => ctx.Builder.ResourceService.GetResource <object>(v.Key))
                          .Do(obj => xaml.SetValue(ctx.PropertyName, obj))));
        }
Пример #4
0
        public Action <T> Setter <T>(SetterContext ctx)
        {
            var converter = ctx.PropertyType
                            .MayHaveConverter()
                            .Get(cA => cA.ConverterTypeName)
                            .Get(Type.GetType)
                            .Get(Activator.CreateInstance)
                            .Cast <TypeConverter>();

            return(xaml => xaml.SetValue(ctx.PropertyName, converter.Value.ConvertFrom(null, System.Globalization.CultureInfo.InvariantCulture, ctx.Value)));
        }
Пример #5
0
 public bool Match(SetterContext ctx)
 {
     return(ctx.PropertyType.CanBeCastTo <IList>() && ctx.Value.CanBeCastTo <object[]>());
 }
Пример #6
0
 public bool Match(SetterContext ctx)
 {
     return(ctx.PropertyType.IsAssignableFrom(ctx.Value.GetType()));
 }
Пример #7
0
 public Action <T> Setter <T>(SetterContext ctx)
 {
     return(xaml => xaml.SetValue(ctx.PropertyName, ctx.Value));
 }
Пример #8
0
 public bool Match(SetterContext ctx)
 {
     return(ctx.PropertyType.MayHaveConverter());
 }
Пример #9
0
 public void AddSetterWith(SetterContext setterContext)
 {
     setterContext.Builder = _builder;
     _recordedActions.Add(_builder.SetterFactory.GetSetter <T>(setterContext));
 }
Пример #10
0
 public bool Match(SetterContext ctx)
 {
     return(ctx.Value.CanBeCastTo <StaticResource>());
 }