本文整理汇总了C#中IHttpRequest.GetAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# IHttpRequest.GetAttributes方法的具体用法?C# IHttpRequest.GetAttributes怎么用?C# IHttpRequest.GetAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHttpRequest
的用法示例。
在下文中一共展示了IHttpRequest.GetAttributes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetResponse
public override object GetResponse(IHttpRequest httpReq, IHttpResponse httpRes, object request)
{
var response = ExecuteService(request,
HandlerAttributes | httpReq.GetAttributes(), httpReq, httpRes);
return response;
}
示例2: AssertAccess
protected bool AssertAccess(IHttpRequest httpReq, IHttpResponse httpRes, string operationName)
{
if (!EndpointHost.Config.HasFeature(Feature.Metadata))
{
EndpointHost.Config.HandleErrorResponse(httpReq, httpRes, HttpStatusCode.Forbidden, "Metadata Not Available");
return false;
}
if (EndpointHost.Config.MetadataVisibility != EndpointAttributes.Any)
{
var actualAttributes = httpReq.GetAttributes();
if ((actualAttributes & EndpointHost.Config.MetadataVisibility) != EndpointHost.Config.MetadataVisibility)
{
EndpointHost.Config.HandleErrorResponse(httpReq, httpRes, HttpStatusCode.Forbidden, "Metadata Not Visible");
return false;
}
}
if (operationName == null) return true; //For non-operation pages we don't need to check further permissions
if (!EndpointHost.Config.EnableAccessRestrictions) return true;
if (!EndpointHost.Config.MetadataPagesConfig.IsVisible(httpReq, Format, operationName))
{
EndpointHost.Config.HandleErrorResponse(httpReq, httpRes, HttpStatusCode.Forbidden, "Service Not Available");
return false;
}
return true;
}
示例3: ProcessRequest
public override void ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, string operationName)
{
var isDebugRequest = httpReq.RawUrl.ToLower().Contains("debug");
if (!isDebugRequest)
{
base.ProcessRequest(httpReq, httpRes, operationName);
return;
}
try
{
var request = CreateRequest(httpReq, operationName);
var response = ExecuteService(request,
HandlerAttributes | httpReq.GetAttributes(), httpReq, httpRes);
WriteDebugResponse(httpRes, response);
}
catch (Exception ex)
{
if (!EndpointHost.Config.WriteErrorsToResponse) throw;
HandleException(httpReq, httpRes, operationName, ex);
}
}
示例4: CanAccess
public bool CanAccess(IHttpRequest httpReq, Format format, string operationName)
{
var reqAttrs = httpReq.GetAttributes();
return CanAccess(reqAttrs, format, operationName);
}
示例5: IsVisible
public bool IsVisible(IHttpRequest httpReq, Operation operation)
{
if (EndpointHost.Config != null && !EndpointHost.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, reqAttrs);
return showToNetwork;
}
示例6: HasAccessToMetadata
public bool HasAccessToMetadata(IHttpRequest httpReq, IHttpResponse httpRes)
{
if (!HasFeature(Feature.Metadata))
{
EndpointHost.Config.HandleErrorResponse(httpReq, httpRes, HttpStatusCode.Forbidden, "Metadata Not Available");
return false;
}
if (MetadataVisibility != EndpointAttributes.Any)
{
var actualAttributes = httpReq.GetAttributes();
if ((actualAttributes & MetadataVisibility) != MetadataVisibility)
{
HandleErrorResponse(httpReq, httpRes, HttpStatusCode.Forbidden, "Metadata Not Visible");
return false;
}
}
return true;
}
示例7: GetResponse
public override object GetResponse(IHttpRequest httpReq, IHttpResponse httpRes, object request)
{
var requestContentType = ContentType.GetEndpointAttributes(httpReq.ResponseContentType);
return ExecuteService(request,
HandlerAttributes | requestContentType | httpReq.GetAttributes(), httpReq, httpRes);
}
示例8: IsVisible
public bool IsVisible(IHttpRequest httpReq, Format format, string operationName)
{
Operation operation;
OperationNamesMap.TryGetValue(operationName.ToLower(), out operation);
if (operation == null) return false;
var reqAttrs = httpReq.GetAttributes();
var canCall = HasImplementation(operation, format);
if (!canCall) return false;
if (operation.RestrictTo == null) return true;
var visbleToNetwork = CanShowToNetwork(operation, reqAttrs);
if (!visbleToNetwork) return false;
var allowsFormat = operation.RestrictTo.CanShowTo((EndpointAttributes)(long)format);
return allowsFormat;
}
示例9: IsVisible
public bool IsVisible(IHttpRequest httpReq, Format format, string operationName)
{
if (EndpointHost.Config != null && !EndpointHost.Config.EnableAccessRestrictions)
return true;
Operation operation;
OperationNamesMap.TryGetValue(operationName.ToLower(), out operation);
if (operation == null) return false;
var canCall = HasImplementation(operation, format);
if (!canCall) return false;
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, reqAttrs);
if (!showToNetwork) return false;
var allowsFormat = operation.RestrictTo.CanShowTo((EndpointAttributes)(long)format);
return allowsFormat;
}