本文整理汇总了C#中IBindingContext.Service方法的典型用法代码示例。如果您正苦于以下问题:C# IBindingContext.Service方法的具体用法?C# IBindingContext.Service怎么用?C# IBindingContext.Service使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBindingContext
的用法示例。
在下文中一共展示了IBindingContext.Service方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Bind
public object Bind(Type type, IBindingContext context)
{
var jsonModel = context
.Service<IFubuRequest>()
.Get<JsonModel>();
return context
.Service<IJsonService>()
.Deserialize(type, jsonModel.Body);
}
示例2: Bind
public override void Bind(PropertyInfo property, IBindingContext context)
{
context.Service<IRequestHeaders>().Value<string>(_headerName, val =>
{
property.SetValue(context.Object, val, null);
});
}
示例3: 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);
}
}
示例4: 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);
}
示例5: Bind
public void Bind(Type type, object instance, IBindingContext context)
{
var request = context.Service<IFubuRequest>();
_types.ForEachProperty(type, prop =>
{
var value = request.Get(prop.PropertyType);
prop.SetValue(instance, value, null);
});
}
示例6: Bind
public object Bind(Type type, IBindingContext context)
{
var path = FindPath(context.Service<AggregateDictionary>());
object instance = Activator.CreateInstance(type, path);
// Setting additional properties
_binder.Bind(type, instance, context);
return instance;
}
示例7: 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;
}
示例8: Bind
public object Bind(Type type, IBindingContext context)
{
var request = context.Service<ICurrentHttpRequest>();
var contentType = request.GetHeader(HttpRequestHeader.ContentType).FirstOrDefault() ??
MimeType.HttpFormMimetype;
var acceptType = ReadAcceptType(request.GetHeader(HttpRequestHeader.Accept));
var currentMimeType = new CurrentMimeType(contentType, acceptType);
return currentMimeType;
}
示例9: Bind
public object Bind(Type type, IBindingContext context)
{
var mimetypeContext = context.Service<MimetypeContext>();
var contentType = mimetypeContext.ContentType;
var acceptType = mimetypeContext.Accepts;
var currentMimeType = new CurrentMimeType(contentType, acceptType);
mimetypeContext.Correct(currentMimeType);
return currentMimeType;
}
示例10: 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;
}
示例11: Bind
public object Bind(Type type, IBindingContext context)
{
var contentType = context.ValueAs<string>("Content-Type");
var acceptType = context.ValueAs<string>("Accept");
var currentMimeType = new CurrentMimeType(contentType, acceptType);
// Life just doesn't get to be simple. What if a jquery plugin, just pulling an example out of
// very thick air, posts json, but with an incorrect mimetype?
if (currentMimeType.ContentType == MimeType.HttpFormMimetype && context.IsAjaxRequest())
{
var streamingData = context.Service<IStreamingData>();
if (streamingData.CouldBeJson())
{
currentMimeType.ContentType = MimeType.Json.Value;
}
}
return currentMimeType;
}
示例12: Bind
public void Bind(PropertyInfo property, IBindingContext context)
{
var log = context.Service<IRequestLogBuilder>().BuildForCurrentRequest();
property.SetValue(context.Object, log, null);
}
示例13: Bind
public void Bind(PropertyInfo property, IBindingContext context)
{
var request = context.Service<IHttpRequest>();
property.SetValue(context.Object, request.FullUrl(), null);
}
示例14: Bind
public void Bind(PropertyInfo property, IBindingContext context)
{
var user = context.Service<IFubuRequest>();
property.SetValue(context.Object, user, null);
}
示例15: Bind
public void Bind(PropertyInfo property, IBindingContext context)
{
var account = context.Service<IUserAccountService>().GetCurrent();
property.SetValue(context.Object, account, null);
}