예제 #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));
            }
        }
예제 #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));
            }
        }
예제 #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]));
 }
예제 #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])));
        }
예제 #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]));
        }
예제 #6
0
파일: BindHandler.cs 프로젝트: flq/XamlTags
        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));
        }
예제 #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));
        }
예제 #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]));
        }
예제 #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]));
        }
예제 #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);
                                                 });
            }
        }
예제 #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);
                    }
                });
            }
        }
예제 #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])));
 }