本文整理汇总了C#中System.Web.Http.Controllers.HttpActionContext.HasMarkerAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# HttpActionContext.HasMarkerAttribute方法的具体用法?C# HttpActionContext.HasMarkerAttribute怎么用?C# HttpActionContext.HasMarkerAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Http.Controllers.HttpActionContext
的用法示例。
在下文中一共展示了HttpActionContext.HasMarkerAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnActionExecuting
/// <summary>
///
/// </summary>
/// <param name="actionContext"></param>
public override void OnActionExecuting(HttpActionContext actionContext)
{
ServiceContainer.Resolve<IInitRequestScopeContext>().BeginRequest(actionContext.Request);
if (!actionContext.HasMarkerAttribute<NonTracingAttribute>())
{
var request = actionContext.Request;
IRequestModel<Header> reqModel = null;
Header reqHeader = null;
if (actionContext.ActionArguments.Count > 0)
{
foreach (var dic in actionContext.ActionArguments)
{
//if (dic.Value is RequestModel)
//{
// reqModel = dic.Value as RequestModel;
// break;
//}
reqModel = dic.Value as IRequestModel<Header>;
if (reqModel != null)
{
break;
}
}
}
if (reqModel == null && actionContext.Request.Content != null && string.Equals(actionContext.Request.Method.Method, "post", StringComparison.CurrentCultureIgnoreCase))
{
try
{
reqModel = actionContext.Request.Content.ReadAsAsync<RequestModel>().Result;
}
catch { }
if (reqModel != null)
{
actionContext.ActionArguments.Add(Guid.NewGuid().ToString("N"), reqModel);
}
}
if (reqModel != null && reqModel.Header != null)
{
reqHeader = reqModel.Header;
if (string.IsNullOrWhiteSpace(reqHeader.TraceID))
{
reqHeader.TraceID = Util.GetUniqueCode32();
}
if (string.IsNullOrWhiteSpace(reqHeader.RpcID))
{
reqHeader.RpcID = "0";
}
//HttpContentData.SetTrackID(reqHeader.TraceID);
//HttpContentData.SubRpcID = reqHeader.RpcID + ".0";
//var header = HttpContentData.CloneRequestHeader(reqModel.Header);
//header.RpcID = header.RpcID + ".0";
}
else
{
reqHeader = TracingContextData.GetDefaultRequestHeader();
//HttpContentData.SetTrackID(reqHeader.TraceID);
}
TracingContextData.SetSubRpcID(reqHeader.RpcID + ".0");
TracingContextData.SetRequestHeader(reqHeader);
//HttpContentData.RequestHeader = reqHeader;
//Not To Log
if (!actionContext.HasMarkerAttribute<NotToLogAttribute>())
{
TraceLogs trace = new TraceLogs();
trace.ContextType = ContextType.Server.ToString();
trace.StartTime = DateTime.Now;
trace.MachineAddr = Util.TracingContextHelper.GetServerAddress();
trace.TraceId = reqHeader.TraceID;
trace.RpcId = reqHeader.RpcID;
trace.Protocol = actionContext.Request.RequestUri.Scheme;
trace.Environment = this.environment ?? EnvironmentConfig.Environment;
trace.SystemID = this.systemID ?? EnvironmentConfig.SystemID;
trace.SystemName = this.systemName ?? EnvironmentConfig.SystemName;
//InvokeID
trace.InvokeID = request.RequestUri.AbsolutePath;
IEnumerable<string> folder;
if (actionContext.Request.Headers.TryGetValues(Config.ResponseHeaderFolderKey, out folder))
{
trace.ServerHost = actionContext.Request.RequestUri.Host + folder.FirstOrDefault();
}
else
{
trace.ServerHost = actionContext.Request.RequestUri.Host;
}
//SearchKey
var searchKey = reqModel as ISearchKey;
if (searchKey != null)
{
//.........这里部分代码省略.........