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


C# IBindingContext.Bind方法代码示例

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


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

示例1: BindWhere

        public static WhereExpression BindWhere(PipelineExpression pipeline, IBindingContext bindingContext, LambdaExpression lambda)
        {
            bindingContext.AddExpressionMapping(lambda.Parameters[0], pipeline.Projector);

            var predicate = bindingContext.Bind(lambda.Body);

            return new WhereExpression(
                pipeline.Source,
                lambda.Parameters[0].Name,
                predicate);
        }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:11,代码来源:BinderHelper.cs

示例2: Bind

        public bool Bind(object instance, PropertyInfo propertyInfo, IBindingContext bindingContext)
        {
            using (bindingContext.OpenChildContext(string.Format("{0}_", propertyInfo.Name)))
            {
                var obj = bindingContext.Bind(propertyInfo.PropertyType);
                if (obj == null) return false;

                propertyInfo.SetValue(instance, obj, new object[0]);
                return true;
            }
        }
开发者ID:UStack,项目名称:UWeb,代码行数:11,代码来源:ComplexTypePropertyBinder.cs

示例3: BindSelect

        public static SelectExpression BindSelect(PipelineExpression pipeline, IBindingContext bindingContext, LambdaExpression lambda)
        {
            bindingContext.AddExpressionMapping(lambda.Parameters[0], pipeline.Projector);

            var selector = bindingContext.Bind(lambda.Body);

            return new SelectExpression(
                pipeline.Source,
                lambda.Parameters[0].Name,
                selector);
        }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:11,代码来源:BinderHelper.cs

示例4: Bind

        public bool Bind(object instance, PropertyInfo propertyInfo, IBindingContext bindingContext)
        {
            var type = propertyInfo.PropertyType;
            var itemType = type.GetGenericArguments()[0];
            if (type.IsInterface)
            {
                type = typeof(List<>).MakeGenericType(itemType);
            }

            var currentCollection = propertyInfo.GetValue(instance, null);
            var collection = currentCollection ?? Activator.CreateInstance(type);
            var collectionType = collection.GetType();

            Func<Type, string, bool> addToCollection = (typeToBind, prefix) =>
                                                           {
                                                               using (bindingContext.OpenChildContext(prefix))
                                                               {
                                                                   var addMethod = AddMethods[collectionType];
                                                                   var obj = bindingContext.Bind(itemType);
                                                                   if (obj != null)
                                                                   {
                                                                       addMethod.Invoke(collection, new[] { obj });
                                                                       return true;
                                                                   }
                                                                   return false;
                                                               }
                                                           };

            var formatString = string.Format("{0}{1}", bindingContext.GetPrefix(), propertyInfo.Name) + "[{0}]_";

            var index = 0;
            string currentPrefix;
            do
            {
                currentPrefix = formatString.ToFormat(index.ToString());
                index++;
            } while (addToCollection(itemType, currentPrefix));

            propertyInfo.SetValue(instance, collection, null);

            return ((IEnumerable) collection).OfType<object>().Count() > 0;
        }
开发者ID:UStack,项目名称:UWeb,代码行数:42,代码来源:CollectionPropertyBinder.cs


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