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


C# IBindingContext.BindProperties方法代码示例

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


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

示例1: 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

示例2: Bind

        public object Bind(Type type, IBindingContext context)
        {
            var path = FindPath(context.Service<IRequestData>());
            object instance = Activator.CreateInstance(type, path);

            // Setting additional properties
            // TODO -- have this delegate to a new method on BindingContext instead
            context.BindProperties(instance);

            return instance;
        }
开发者ID:chribben,项目名称:fubumvc,代码行数:11,代码来源:ResourcePathBinder.cs

示例3: Bind

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

            // let the default binders set all the route values and things
            context.BindProperties(instance);

            var data = context.Service<IStreamingData>().InputText();

            var x = XDocument.Parse(data);

            // TODO - simple implementation. Would be susceptible to overwriting route values from query and url
            foreach (var element in x.Root.Elements())
            {
                SetProperty(type, instance, element, element.Name.ToString());
            }

            return instance;
        }
开发者ID:nieve,项目名称:FubuRESTInnovation,代码行数:19,代码来源:PutRequestBinder.cs

示例4: Bind

 public object Bind(Type type, IBindingContext context)
 {
     object model = Activator.CreateInstance(type);
     context.BindProperties(model);
     return model;
 }
开发者ID:rauhryan,项目名称:awesomesauce,代码行数:6,代码来源:EntityModelBinder.cs


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