• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IBindingContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Bind

        public object Bind(Type type, IBindingContext context)
        {
            var model = Activator.CreateInstance(type);
            Bind(type, model, context);

            return model;
        }
开发者ID:joemcbride,项目名称:fubumvc,代码行数:7,代码来源:FubuRequestTuple.cs


示例2: GetOrCreateBoundExpression

        public BoundExpression GetOrCreateBoundExpression(IBindingContext binder, BoundExpressionOptions options)
        {
            Require.NotNull(binder, "binder");
            Require.NotNull(options, "options");

            var key = new CacheKey(
                _dynamicExpression.ParseResult.Identifiers,
                !DynamicExpression.IsLanguageCaseSensitive(_dynamicExpression.Language),
                binder,
                options
            );

            lock (_syncRoot)
            {
                BoundExpression boundExpression;

                if (!_cache.TryGetValue(key, out boundExpression))
                {
                    boundExpression = new BoundExpression(
                        _dynamicExpression,
                        key.OwnerType,
                        key.Imports,
                        key.IdentifierTypes,
                        key.Options
                    );

                    _cache.Add(key, boundExpression);
                }

                return boundExpression;
            }
        }
开发者ID:parsnips,项目名称:Expressions,代码行数:32,代码来源:BoundExpressionCache.cs


示例3: Bind

        public object Bind(Type type, IBindingContext context)
        {
            var instance = Activator.CreateInstance(type);
            Bind(type, instance, context);

            return instance;
        }
开发者ID:nieve,项目名称:fubucore,代码行数:7,代码来源:StandardModelBinder.cs


示例4: GetViewForViewModel

        public static object GetViewForViewModel(this IDataTemplate template, IBindingContext context, object viewModel, Func<object, object> getConvertView, params object[] args)
        {
            if (template != null)
            {
                var cell = getConvertView(template.Id);
                if (cell != null && template.ViewType != null)
                {
                    if (!template.ViewType.IsAssignableFrom(cell.GetType()))
                    {
                        cell = null;
                    }
                }

                if (cell == null)
                {
                    cell = template.CreateView(args);
                }

                template.InitializeView(cell);
                context.Bindings.ClearBindings(cell);
                template.BindViewModel(context, viewModel, cell);
                return cell;
            }

            return null;
        }
开发者ID:sgmunn,项目名称:Mobile.Mvvm,代码行数:26,代码来源:DataTemplateExtensions.cs


示例5: Bind

        public object Bind(Type inputModelType, IBindingContext context)
        {
            //we determine the type by sniffing the ctor arg
            var entityType = inputModelType
                .GetConstructors()
                .Single(x => x.GetParameters().Count() == 1)
                .GetParameters()
                .Single()
                .ParameterType;

            var entity = tryFindExistingEntity(entityType, context)
                ?? createNewEntity(entityType, context);

            var model = (EditEntityModel)Activator.CreateInstance(inputModelType, entity);

            context.BindProperties(model);

            // Get the binding errors from conversion of the EditEntityModel
            context.Problems.Each(x =>
            {
                model.Notification.RegisterMessage(x.Property, FastPackKeys.PARSE_VALUE);
            });

            return model;
        }
开发者ID:DarthFubuMVC,项目名称:FubuFastPack,代码行数:25,代码来源:EditEntityModelBinder.cs


示例6: populate

 private void populate(Type type, IBindingContext context)
 {
     _typeCache.ForEachProperty(type, prop =>
     {
         _propertyBinders.BinderFor(prop).Bind(prop, context);
     });
 }
开发者ID:joedivec,项目名称:fubumvc,代码行数:7,代码来源:StandardModelBinder.cs


示例7: NewGame

	public static Game NewGame(IBindingContext context)
	{
		WorldLogicCoordinateTransform transformer = new WorldLogicCoordinateTransform(0.32f,10,10);
		var boardView = context.Get<BoardView> (InnerBindingNames.Empty,10,10,transformer);

		return new Game(boardView);
	}
开发者ID:ericknajjar,项目名称:taticsthegame,代码行数:7,代码来源:Game.cs


示例8: Bind

        public void Bind(PropertyInfo property, IBindingContext context)
        {
            var type = property.PropertyType;
            var itemType = type.GetGenericArguments()[0];
            if (type.IsInterface)
            {
                type = _collectionTypeProvider.GetCollectionType(type, itemType);
            }

            object collection = Activator.CreateInstance(type);
            var collectionType = collection.GetType();

            Func<object, bool> addToCollection = obj =>
                {
                    if (obj != null)
                    {
                        var addMethod = _addMethods[collectionType];
                        addMethod.Invoke(collection, new[] {obj});
                        return true;
                    }
                    return false;
                };

            var formatString = property.Name + "[{0}]";

            int index = 0;
            string prefix;
            do
            {
                prefix = formatString.ToFormat(index);
                index++;
            } while (addToCollection(context.BindObject(prefix, itemType)));

            property.SetValue(context.Object, collection, null);
        }
开发者ID:chadmyers,项目名称:fubucore,代码行数:35,代码来源:CollectionPropertyBinder.cs


示例9: Bind

 public override void Bind(PropertyInfo property, IBindingContext context)
 {
     context.Service<IRequestHeaders>().Value<string>(_headerName, val =>
     {
         property.SetValue(context.Object, val, null);
     });
 }
开发者ID:roend83,项目名称:fubumvc,代码行数:7,代码来源:HeaderValueAttribute.cs


示例10: Bind

        public object Bind(Type type, IBindingContext context)
        {
            var entityType = type.GetConstructors().Single(x => x.GetParameters().Count() == 1).GetParameters().Single().ParameterType;

            // This is our convention.
            var prefix = entityType.Name;
            var prefixedContext = context.PrefixWith(prefix);

            DomainEntity entity = tryFindExistingEntity(context, prefixedContext, entityType) ?? createNewEntity(entityType, prefixedContext);

            var model = (EditEntityModel)Activator.CreateInstance(type, entity);

            // Get the binding errors from conversion of the Entity
            prefixedContext.Problems.Each(x =>
            {
                model.Notification.RegisterMessage(x.Properties.Last(), FastPackKeys.PARSE_VALUE);
            });

            _innerBinder.Bind(type, model, context);

            // Get the binding errors from conversion of the EditEntityModel
            context.Problems.Each(x =>
            {
                model.Notification.RegisterMessage(x.Properties.Last(), FastPackKeys.PARSE_VALUE);
            });

            return model;
        }
开发者ID:pjdennis,项目名称:fubumvc,代码行数:28,代码来源:EditEntityModelBinder.cs


示例11: Bind

 public void Bind(PropertyInfo property, IBindingContext context)
 {
     property.ForAttribute<BindingAttribute>(att =>
     {
         att.Bind(property, context);
     });
 }
开发者ID:marcusswope,项目名称:Hit-That-Line,代码行数:7,代码来源:AttributePropertyBinder.cs


示例12: createNewEntity

        private DomainEntity createNewEntity(Type entityType, IBindingContext prefixedContext)
        {
            var entity = (DomainEntity)_innerBinder.Bind(entityType, prefixedContext);
            entity.Id = Guid.Empty;
            _entityDefaults.ApplyDefaultsToNewEntity(entity);

            return entity;
        }
开发者ID:pjdennis,项目名称:fubumvc,代码行数:8,代码来源:EditEntityModelBinder.cs


示例13: Bind

        public object Bind(Type type, IBindingContext context)
        {
            var contentType = context.Data.ValueAs<string>("Content-Type");
            var acceptType = context.Data.ValueAs<string>("Accept");
            var currentMimeType = new CurrentMimeType(contentType, acceptType);

            return currentMimeType;
        }
开发者ID:roend83,项目名称:fubumvc,代码行数:8,代码来源:CurrentMimeTypeModelBinder.cs


示例14: EmbeddedPipelineBindingContext

        public EmbeddedPipelineBindingContext(IBindingContext parent)
        {
            _parent = Ensure.IsNotNull(parent, nameof(parent));

            _correlationMapping = new Dictionary<Expression, Guid>();
            _expressionMapping = new Dictionary<Expression, Expression>();
            _memberMapping = new Dictionary<MemberInfo, Expression>();
        }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:8,代码来源:EmbeddedPipelineBindingContext.cs


示例15: Bind

 public void Bind(PropertyInfo property, IBindingContext context)
 {
     var fubuRequest = context.Service<IFubuRequest>();
     var modelType = property.PropertyType;
     if (fubuRequest.Has(modelType))
     {
         property.SetValue(context.Object, fubuRequest.Get(modelType), null);
     }
 }
开发者ID:emiaj,项目名称:ProductsManagement,代码行数:9,代码来源:OriginalModelBinder.cs


示例16: Bind

        public void Bind(PropertyInfo property, IBindingContext context)
        {
            var httpContext = context.Service<HttpContextBase>();
            var ipAddress = httpContext.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (string.IsNullOrWhiteSpace(ipAddress)) ipAddress = httpContext.Request.ServerVariables["HTTP_X_FORWARDED"];
            if (string.IsNullOrWhiteSpace(ipAddress)) ipAddress = httpContext.Request.UserHostAddress;

            property.SetValue(context.Object, ipAddress, null);
        }
开发者ID:marcusswope,项目名称:Hit-That-Line,代码行数:9,代码来源:IPAddressPropertyBinder.cs


示例17: Bind

 public object Bind(Type type, IBindingContext context)
 {
     var jsonModel = context
                         .Service<IFubuRequest>()
                         .Get<JsonModel>();
     return context
             .Service<IJsonService>()
             .Deserialize(type, jsonModel.Body);
 }
开发者ID:jmlopez,项目名称:Valcon,代码行数:9,代码来源:HelloWorldFubuRegistry.cs


示例18: Bind

 public void Bind(PropertyInfo property, IBindingContext context)
 {
     context.ForProperty(property, () =>
     {
         ValueConverter converter = _converters.FindConverter(property);
         object value = converter(context);
         property.SetValue(context.Object, value, null);
     });
 }
开发者ID:JamieDraperUK,项目名称:fubumvc,代码行数:9,代码来源:ConversionPropertyBinder.cs


示例19: PopulatePropertyWithBinder

 public static void PopulatePropertyWithBinder(PropertyInfo property, IBindingContext context,
                                               IPropertyBinder propertyBinder)
 {
     context.Logger.Chose(property, propertyBinder);
     context.ForProperty(property, propertyContext =>
     {
         propertyBinder.Bind(property, context);
     });
 }
开发者ID:marcusswope,项目名称:Hit-That-Line,代码行数:9,代码来源:StandardModelBinder.cs


示例20: Bind

        public bool Bind(object instance, PropertyInfo propertyInfo, IBindingContext bindingContext)
        {
            if (!bindingSourceCollection.ContainsKey(bindingContext.GetKey(propertyInfo.Name)))
                return false;

            propertyInfo.SetValue(instance, valueConverterCollection.Convert(propertyInfo.PropertyType,
                                                                             bindingSourceCollection.Get(bindingContext.GetKey(propertyInfo.Name))), new object[0]);

            return true;
        }
开发者ID:UStack,项目名称:UWeb,代码行数:10,代码来源:SimpleTypePropertyBinder.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IBindingMemberInfo类代码示例发布时间:2022-05-24
下一篇:
C# IBinding类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap