当前位置: 首页>>代码示例>>C#>>正文


C# BindingBuilder.Add方法代码示例

本文整理汇总了C#中BindingBuilder.Add方法的典型用法代码示例。如果您正苦于以下问题:C# BindingBuilder.Add方法的具体用法?C# BindingBuilder.Add怎么用?C# BindingBuilder.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BindingBuilder的用法示例。


在下文中一共展示了BindingBuilder.Add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuilderShouldUseEventArgs2

        public void BuilderShouldUseEventArgs2()
        {
            var builder = new BindingBuilder();
            builder.Bind(new object(), "empty").To<BindingSourceModel>(() => model => BindingSyntaxEx.EventArgs<EventArgs>().GetType().Name);

            builder.Add(BindingConstants.CurrentEventArgs, EventArgs.Empty);
            var expression = builder.GetData(BindingBuilderConstants.MultiExpression);
            expression(builder, Empty.Array<object>()).ShouldEqual(EventArgs.Empty.GetType().Name);
        }
开发者ID:windygu,项目名称:MugenMvvmToolkit,代码行数:9,代码来源:BindingSyntaxExtensionsTest.cs

示例2: BuilderShouldUseEventArgs3

        public void BuilderShouldUseEventArgs3()
        {
            var builder = new BindingBuilder();
            builder.Bind(new object(), "empty").To<BindingSourceModel>(() => model => BindingSyntaxEx.EventArgs<BindingSourceModel>().ObjectProperty);

            var sourceModel = new BindingSourceModel { ObjectProperty = "test" };
            builder.Add(BindingConstants.CurrentEventArgs, sourceModel);
            var expression = builder.GetData(BindingBuilderConstants.MultiExpression);
            expression(builder, Empty.Array<object>()).ShouldEqual(sourceModel.ObjectProperty);
        }
开发者ID:windygu,项目名称:MugenMvvmToolkit,代码行数:10,代码来源:BindingSyntaxExtensionsTest.cs

示例3: BuilderShouldUseEventArgsForParameter2

        public void BuilderShouldUseEventArgsForParameter2()
        {
            var builder = new BindingBuilder();
            builder.Bind(new object(), "empty").To<BindingSourceModel>(() => m => m.IntProperty)
                .WithCommandParameter(() => model => BindingSyntaxEx.EventArgs<EventArgs>().GetType().Name);

            builder.Add(BindingConstants.CurrentEventArgs, EventArgs.Empty);
            var expression = builder.GetData(BindingBuilderConstants.CommandParameter);
            expression(builder).ShouldEqual(EventArgs.Empty.GetType().Name);
        }
开发者ID:windygu,项目名称:MugenMvvmToolkit,代码行数:10,代码来源:BindingSyntaxExtensionsTest.cs

示例4: ParserShouldParseMultiExpressionWithConverter

        public void ParserShouldParseMultiExpressionWithConverter()
        {
            const string targetPath = "Text";
            const string sourcePath1 = "SourceText1";
            const string sourcePath2 = "SourceText2";
            const string converterName = "TestConverter";
            const string binding = "Text $TestConverter(SourceText1, SourceText2)";
            var target = new object();
            var args = new object[] { "tset", 1 };
            var sourceModel = new BindingSourceModel { IntProperty = int.MaxValue };
            var bindingMock = new DataBindingMock
            {
                TargetAccessor = new BindingSourceAccessorMock
                {
                    Source = new BindingSourceMock
                    {
                        GetPathMembers = b => new BindingPathMembersMock(this, BindingPath.Create("IntProperty"), new BindingMemberInfo("IntProperty", BindingSourceModel.IntPropertyInfo, typeof(BindingSourceModel)))
                    }
                }
            };

            var converterMock = new ValueConverterCoreMock
            {
                Convert = (o, type, arg3, arg4) =>
                {
                    type.ShouldEqual(BindingSourceModel.IntPropertyInfo.PropertyType);
                    o.ShouldEqual(args[0]);
                    arg3.ShouldEqual(args[1]);
                    return sourceModel;
                }
            };
            var provider = new BindingProvider();
            var resolver = new BindingResourceResolver();
            BindingServiceProvider.ResourceResolver = resolver;
            resolver.AddConverter(converterName, converterMock, true);
            IBindingParser bindingParser = CreateBindingParser(bindingProvider: provider);

            var context = new BindingBuilder(bindingParser.Parse(binding, EmptyContext, target, null).Single());
            context.Add(BindingConstants.Binding, bindingMock);

            IBindingPath path = context.GetData(BindingBuilderConstants.TargetPath);
            path.Path.ShouldEqual(targetPath);

            var expression = context.GetData(BindingBuilderConstants.MultiExpression);
            expression(context, args).ShouldEqual(sourceModel);

            var sources = context.GetData(BindingBuilderConstants.Sources);
            BindingSourceShouldBeValidDataContext(target, sources[0].Invoke(context), sourcePath1);
            BindingSourceShouldBeValidDataContext(target, sources[1].Invoke(context), sourcePath2);
        }
开发者ID:windygu,项目名称:MugenMvvmToolkit,代码行数:50,代码来源:BindingParserTest.cs

示例5: ParserShouldParseExpressionWithEventArgs

        public void ParserShouldParseExpressionWithEventArgs()
        {
            const string targetPath = "Text";
            const string binding = @"Text $args";
            IBindingParser bindingParser = CreateBindingParser();

            var context = new BindingBuilder(bindingParser.Parse(binding, EmptyContext, new object(), null).Single());
            var path = context.GetData(BindingBuilderConstants.TargetPath);
            path.Path.ShouldEqual(targetPath);

            context.Add(BindingConstants.CurrentEventArgs, EventArgs.Empty);
            var expression = context.GetData(BindingBuilderConstants.MultiExpression);
            expression(context, Empty.Array<object>()).ShouldEqual(EventArgs.Empty);
        }
开发者ID:windygu,项目名称:MugenMvvmToolkit,代码行数:14,代码来源:BindingParserTest.cs

示例6: CreateBuildersFromString

 public IList<IBindingBuilder> CreateBuildersFromString(object target, string bindingExpression, IList<object> sources = null)
 {
     Should.NotBeNull(target, "target");
     Should.NotBeNullOrWhitespace(bindingExpression, "bindingExpression");
     try
     {
         var parserResult = Parser.Parse(bindingExpression, DataContext.Empty, target, sources);
         var result = new IBindingBuilder[parserResult.Count];
         for (int index = 0; index < parserResult.Count; index++)
         {
             var builder = new BindingBuilder(parserResult[index]);
             builder.Add(BindingBuilderConstants.BuildDelegate, _buildDelegate);
             result[index] = builder;
         }
         return result;
     }
     catch (Exception exception)
     {
         exception = new InvalidOperationException(exception.Message, exception);
         var builder = new BindingBuilder();
         builder.Add(BindingBuilderConstants.Target, target);
         builder.Add(ProviderConstant, this);
         builder.Add(ExceptionConstant, exception);
         builder.Add(BindingBuilderConstants.BuildDelegate, CreateInvalidaDataBindingDelegate);
         return new IBindingBuilder[] { builder };
     }
 }
开发者ID:sami1971,项目名称:MugenMvvmToolkit,代码行数:27,代码来源:BindingProvider.cs

示例7: ParserShouldParseExpressionWithBinding

        public void ParserShouldParseExpressionWithBinding()
        {
            const string targetPath = "Text";
            const string binding = @"Text $binding";
            var dataContext = new DataContext();
            var bindingMock = new DataBindingMock { GetContext = () => dataContext };
            IBindingParser bindingParser = CreateBindingParser();

            var context = new BindingBuilder(bindingParser.Parse(new object(), binding, null, null).Single());
            var path = context.GetData(BindingBuilderConstants.TargetPath);
            path.Path.ShouldEqual(targetPath);

            context.Add(BindingConstants.Binding, bindingMock);
            var expression = context.GetData(BindingBuilderConstants.MultiExpression);
            expression(context, Empty.Array<object>()).ShouldEqual(bindingMock);
        }
开发者ID:dbeattie71,项目名称:MugenMvvmToolkit,代码行数:16,代码来源:BindingParserTest.cs


注:本文中的BindingBuilder.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。