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


C# IBindingContext.Service方法代码示例

本文整理汇总了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);
 }
开发者ID:jmlopez,项目名称:Valcon,代码行数:9,代码来源:HelloWorldFubuRegistry.cs

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

示例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);
     }
 }
开发者ID:emiaj,项目名称:ProductsManagement,代码行数:9,代码来源:OriginalModelBinder.cs

示例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);
        }
开发者ID:marcusswope,项目名称:Hit-That-Line,代码行数:9,代码来源:IPAddressPropertyBinder.cs

示例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);
            });
        }
开发者ID:joemcbride,项目名称:fubumvc,代码行数:10,代码来源:FubuRequestTuple.cs

示例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;
        }
开发者ID:jemacom,项目名称:fubumvc,代码行数:11,代码来源:ResourcePathBinder.cs

示例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;
        }
开发者ID:chribben,项目名称:fubumvc,代码行数:11,代码来源:ResourcePathBinder.cs

示例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;
        }
开发者ID:NeilSorensen,项目名称:fubumvc,代码行数:13,代码来源:CurrentMimeTypeModelBinder.cs

示例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;
        }
开发者ID:cothienlac86,项目名称:fubumvc,代码行数:15,代码来源:CurrentMimeTypeModelBinder.cs

示例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;
        }
开发者ID:nieve,项目名称:FubuRESTInnovation,代码行数:19,代码来源:PutRequestBinder.cs

示例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;
        }
开发者ID:hartez,项目名称:fubumvc,代码行数:19,代码来源:CurrentMimeTypeModelBinder.cs

示例12: Bind

 public void Bind(PropertyInfo property, IBindingContext context)
 {
     var log = context.Service<IRequestLogBuilder>().BuildForCurrentRequest();
     property.SetValue(context.Object, log, null);
 }
开发者ID:mtscout6,项目名称:FubuWorld,代码行数:5,代码来源:RequestLogPropertyBinder.cs

示例13: Bind

 public void Bind(PropertyInfo property, IBindingContext context)
 {
     var request = context.Service<IHttpRequest>();
     property.SetValue(context.Object, request.FullUrl(), null);
 }
开发者ID:kingreatwill,项目名称:fubumvc,代码行数:5,代码来源:CurrentRequestFullUrlPropertyBinder.cs

示例14: Bind

 public void Bind(PropertyInfo property, IBindingContext context)
 {
     var user = context.Service<IFubuRequest>();
     property.SetValue(context.Object, user, null);
 }
开发者ID:marcusswope,项目名称:Hit-That-Line,代码行数:5,代码来源:FubuRequestPropertyBinder.cs

示例15: Bind

 public void Bind(PropertyInfo property, IBindingContext context)
 {
     var account = context.Service<IUserAccountService>().GetCurrent();
     property.SetValue(context.Object, account, null);
 }
开发者ID:marcusswope,项目名称:Hit-That-Line,代码行数:5,代码来源:UserAccountPropertyBinder.cs


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