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


C# IRequest.GetAttributes方法代码示例

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


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

示例1: HasAccessToMetadata

        public bool HasAccessToMetadata(IRequest httpReq, IResponse httpRes)
        {
            if (!HasFeature(Feature.Metadata))
            {
                HandleErrorResponse(httpReq, httpRes, HttpStatusCode.Forbidden, "Metadata Not Available");
                return false;
            }

            if (Config.MetadataVisibility != RequestAttributes.Any)
            {
                var actualAttributes = httpReq.GetAttributes();
                if ((actualAttributes & Config.MetadataVisibility) != Config.MetadataVisibility)
                {
                    HandleErrorResponse(httpReq, httpRes, HttpStatusCode.Forbidden, "Metadata Not Visible");
                    return false;
                }
            }
            return true;
        }
开发者ID:JackFong,项目名称:ServiceStack,代码行数:19,代码来源:ServiceStackHost.Runtime.cs

示例2: IsVisible

        public bool IsVisible(IRequest httpReq, Operation operation)
        {
            if (HostContext.Config != null && !HostContext.Config.EnableAccessRestrictions)
                return true;

            if (operation.RestrictTo == null) return true;

            //Less fine-grained on /metadata pages. Only check Network and Format
            var reqAttrs = httpReq.GetAttributes();
            var showToNetwork = CanShowToNetwork(operation.RestrictTo, reqAttrs);
            return showToNetwork;
        }
开发者ID:jrmitch120,项目名称:ServiceStack,代码行数:12,代码来源:ServiceMetadata.cs

示例3: CanAccess

 public bool CanAccess(IRequest httpReq, Format format, string operationName)
 {
     var reqAttrs = httpReq.GetAttributes();
     return CanAccess(reqAttrs, format, operationName);
 }
开发者ID:jrmitch120,项目名称:ServiceStack,代码行数:5,代码来源:ServiceMetadata.cs

示例4: GetRequestInfo

        public static RequestInfoResponse GetRequestInfo(IRequest httpReq)
        {
            int virtualPathCount = 0;
            int.TryParse(httpReq.QueryString["virtualPathCount"], out virtualPathCount);
            var hostType = HostContext.AppHost.GetType();

            var ipv4Addr = "";
            foreach (var entry in ServiceStackHandlerBase.NetworkInterfaceIpv4Addresses)
            {
                if (ipv4Addr.Length > 0)
                    ipv4Addr += ", ";
                ipv4Addr += new IPAddress(entry.Key) + "/" + new IPAddress(entry.Value);
            }

            var ipv6Address = "";
            foreach (var addr in ServiceStackHandlerBase.NetworkInterfaceIpv6Addresses)
            {
                if (ipv6Address.Length > 0)
                    ipv6Address += ", ";
                ipv6Address += new IPAddress(addr);
            }

            var response = new RequestInfoResponse
            {
                Usage = "append '?debug=requestinfo' to any querystring. Optional params: virtualPathCount",
                Host = HostContext.Config.DebugHttpListenerHostEnvironment + "_v" + Env.ServiceStackVersion + "_" + HostContext.ServiceName,
                HostType = "{0} ({1})".Fmt(HostContext.IsAspNetHost ? "ASP.NET" : "SelfHost", hostType.BaseType != null ? hostType.BaseType.Name : hostType.Name),
                Date = DateTime.UtcNow.ToString("yy-MM-dd HH:mm:ss"),
                ServiceName = HostContext.ServiceName,
                HandlerFactoryPath = HostContext.Config.HandlerFactoryPath,
                UserHostAddress = httpReq.UserHostAddress,
                HttpMethod = httpReq.Verb,
                AbsoluteUri = httpReq.AbsoluteUri,
                WebHostUrl = HostContext.Config.WebHostUrl,
                ApplicationBaseUrl = httpReq.GetBaseUrl(),
                ResolveAbsoluteUrl = HostContext.AppHost.ResolveAbsoluteUrl("~/resolve", httpReq),
                RootDirectoryPath = HostContext.VirtualFileSources.RootDirectory.RealPath,
                StripApplicationVirtualPath = HostContext.Config.StripApplicationVirtualPath,
                CurrentDirectory = Directory.GetCurrentDirectory(),
                RawUrl = httpReq.RawUrl,
                ResolvedPathInfo = httpReq.PathInfo,
                ContentType = httpReq.ContentType,
                Headers = ToDictionary(httpReq.Headers),
                QueryString = ToDictionary(httpReq.QueryString),
                FormData = ToDictionary(httpReq.FormData),
                AcceptTypes = new List<string>(httpReq.AcceptTypes ?? TypeConstants.EmptyStringArray),
                ContentLength = httpReq.ContentLength,
                OperationName = httpReq.OperationName,
                ResponseContentType = httpReq.ResponseContentType,
                RequestAttributes = httpReq.GetAttributes().ToString(),
                Ipv4Addresses = ipv4Addr,
                Ipv6Addresses = ipv6Address,
                PluginsLoaded = HostContext.AppHost.PluginsLoaded,
                StartUpErrors = HostContext.AppHost.StartUpErrors,
                AsyncErrors = HostContext.AppHost.AsyncErrors,
                LastRequestInfo = LastRequestInfo,
                VirtualPathProviderFiles = HostContext.AppHost.VirtualFileSources.GetAllMatchingFiles("*").Take(virtualPathCount).Map(x => x.RealPath),
                Stats = new Dictionary<string, string> {
                    {"RawHttpHandlers", HostContext.AppHost.RawHttpHandlers.Count.ToString() },
                    {"PreRequestFilters", HostContext.AppHost.PreRequestFilters.Count.ToString() },
                    {"RequestBinders", HostContext.AppHost.RequestBinders.Count.ToString() },
                    {"GlobalRequestFilters", HostContext.AppHost.GlobalRequestFilters.Count.ToString() },
                    {"GlobalResponseFilters", HostContext.AppHost.GlobalResponseFilters.Count.ToString() },
                    {"CatchAllHandlers", HostContext.AppHost.CatchAllHandlers.Count.ToString() },
                    {"Plugins", HostContext.AppHost.Plugins.Count.ToString() },
                    {"ViewEngines", HostContext.AppHost.ViewEngines.Count.ToString() },
                    {"RequestTypes", HostContext.AppHost.Metadata.RequestTypes.Count.ToString() },
                    {"ResponseTypes", HostContext.AppHost.Metadata.ResponseTypes.Count.ToString() },
                    {"ServiceTypes", HostContext.AppHost.Metadata.ServiceTypes.Count.ToString() },
                    {"RestPaths", HostContext.AppHost.RestPaths.Count.ToString() },
                    {"ContentTypes", HostContext.AppHost.ContentTypes.ContentTypeFormats.Count.ToString() },
                    {"EnableFeatures", HostContext.Config.EnableFeatures.ToString() },
                    {"VirtualPathProvider", HostContext.AppHost.VirtualFileSources.ToString() }
                },
            };
            return response;
        }
开发者ID:CLupica,项目名称:ServiceStack,代码行数:77,代码来源:RequestInfoHandler.cs


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