本文整理汇总了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;
}
示例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;
}
示例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;
}
示例4: Bind
public object Bind(Type type, IBindingContext context)
{
object model = Activator.CreateInstance(type);
context.BindProperties(model);
return model;
}