Ejemplo n.º 1
0
        public void Handle(InvokeContext ctx)
        {
            GuardAgainstSignatureFailures(ctx);
            var attachProp = (DependencyProperty)ctx.Values[0];

            if (ctx.IsArgumentNameSpecified("path"))
                ctx.AddSetterWith(ctx.NewBindSetterContext(attachProp));
            else
            {
                var value = ctx.Values[1];
                ctx.AddSetterWith<DependencyObject>(xaml => xaml.SetValue(attachProp, value));
            }
        }
Ejemplo n.º 2
0
        public void Handle(InvokeContext ctx)
        {
            GuardAgainstSignatureFailures(ctx);
            var attachProp = (DependencyProperty)ctx.Values[0];

            if (ctx.IsArgumentNameSpecified("path"))
            {
                ctx.AddSetterWith(ctx.NewBindSetterContext(attachProp));
            }
            else
            {
                var value = ctx.Values[1];
                ctx.AddSetterWith <DependencyObject>(xaml => xaml.SetValue(attachProp, value));
            }
        }
Ejemplo n.º 3
0
 public void Handle(InvokeContext ctx)
 {
     var propertyName = ctx.Name;
     var propertyType = ctx.XamlType.GetPropertyType(propertyName);
     var values = ctx.NormalizeToBuiltXaml(c => c.Values[0]).MustHaveValue();
     ctx.AddSetterWith(new SetterContext(propertyName, propertyType, values.Length > 1 ? values : values[0]));
 }
Ejemplo n.º 4
0
        public void Handle(InvokeContext ctx)
        {
            var propertyName = ctx.Name.Replace("Static", "");
            var propertyType = ctx.XamlType.GetPropertyType(propertyName);

            ctx.AddSetterWith(new SetterContext(propertyName, propertyType, new StaticResource(ctx.Values[0])));
        }
Ejemplo n.º 5
0
        public void Handle(InvokeContext ctx)
        {
            var propertyName = ctx.Name;
            var propertyType = ctx.XamlType.GetPropertyType(propertyName);
            var values       = ctx.NormalizeToBuiltXaml(c => c.Values[0]).MustHaveValue();

            ctx.AddSetterWith(new SetterContext(propertyName, propertyType, values.Length > 1 ? values : values[0]));
        }
Ejemplo n.º 6
0
        public void Handle(InvokeContext ctx)
        {
            FailIfXamlNotAFrameworkElement(ctx);
            var propertyName = ctx.Name.Replace("OneWayBind", "").Replace("Bind", "");
            var depProp = ctx.XamlType
                .FindDependencyProperty(propertyName)
                .MustHaveValue(new ArgumentException("No DependencyProperty '{0}' found on type '{1}'".Fmt(propertyName, ctx.XamlType.Name)));

            ctx.AddSetterWith(ctx.NewBindSetterContext(depProp));
        }
Ejemplo n.º 7
0
        public void Handle(InvokeContext ctx)
        {
            FailIfXamlNotAFrameworkElement(ctx);
            var propertyName = ctx.Name.Replace("OneWayBind", "").Replace("Bind", "");
            var depProp      = ctx.XamlType
                               .FindDependencyProperty(propertyName)
                               .MustHaveValue(new ArgumentException("No DependencyProperty '{0}' found on type '{1}'".Fmt(propertyName, ctx.XamlType.Name)));

            ctx.AddSetterWith(ctx.NewBindSetterContext(depProp));
        }
Ejemplo n.º 8
0
        public void Handle(InvokeContext ctx)
        {
            FailIfXamlNotAFrameworkElement(ctx);

            object value = null;
            ctx.Values[1].Maybe(
                v => v.Cast<Func<XamlBuilder, Xaml>>()
                    .Get(func => func(ctx.Builder).Create())
                    .Do(xaml => value = xaml),
                v => v.Cast<Xaml>()
                    .Get(x => x.Create())
                    .Do(xaml => value = xaml)
            );

            ctx.AddSetterWith<FrameworkElement>(fw => fw.Resources.Add(ctx.Values[0], value ?? ctx.Values[1]));
        }
Ejemplo n.º 9
0
        public void Handle(InvokeContext ctx)
        {
            FailIfXamlNotAFrameworkElement(ctx);

            object value = null;

            ctx.Values[1].Maybe(
                v => v.Cast <Func <XamlBuilder, Xaml> >()
                .Get(func => func(ctx.Builder).Create())
                .Do(xaml => value = xaml),
                v => v.Cast <Xaml>()
                .Get(x => x.Create())
                .Do(xaml => value = xaml)
                );

            ctx.AddSetterWith <FrameworkElement>(fw => fw.Resources.Add(ctx.Values[0], value ?? ctx.Values[1]));
        }
Ejemplo n.º 10
0
        public void Handle(InvokeContext ctx)
        {
            FailIfIAddChildIsMissing(ctx);

            var values = ctx.Values.Select(v => ctx.NormalizeToBuiltXaml(_ => v).MustHaveValue()).Flatten();

            foreach (var value in values)
            {
                var v = value;
                ctx.AddSetterWith<IAddChild>(ac =>
                                                 {
                                                     if (v.CanBeCastTo<string>())
                                                         ac.AddText((string) v);
                                                     else
                                                         ac.AddChild(v);
                                                 });
            }
        }
Ejemplo n.º 11
0
        public void Handle(InvokeContext ctx)
        {
            FailIfIAddChildIsMissing(ctx);

            var values = ctx.Values.Select(v => ctx.NormalizeToBuiltXaml(_ => v).MustHaveValue()).Flatten();

            foreach (var value in values)
            {
                var v = value;
                ctx.AddSetterWith <IAddChild>(ac =>
                {
                    if (v.CanBeCastTo <string>())
                    {
                        ac.AddText((string)v);
                    }
                    else
                    {
                        ac.AddChild(v);
                    }
                });
            }
        }
Ejemplo n.º 12
0
 public void Handle(InvokeContext ctx)
 {
     var propertyName = ctx.Name.Replace("Static", "");
     var propertyType = ctx.XamlType.GetPropertyType(propertyName);
     ctx.AddSetterWith(new SetterContext(propertyName, propertyType, new StaticResource(ctx.Values[0])));
 }