本文整理汇总了C#中IProcessingContext类的典型用法代码示例。如果您正苦于以下问题:C# IProcessingContext类的具体用法?C# IProcessingContext怎么用?C# IProcessingContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IProcessingContext类属于命名空间,在下文中一共展示了IProcessingContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeforeProcessAsync
/// <summary>
/// Interception called before invoking the handler to process the request.
/// </summary>
/// <param name="context">The processing context.</param>
/// <param name="token">The cancellation token.</param>
/// <returns>
/// A task.
/// </returns>
public Task BeforeProcessAsync(IProcessingContext context, CancellationToken token)
{
Contract.Requires(context != null);
Contract.Ensures(Contract.Result<Task>() != null);
return Contract.Result<Task>();
}
示例2: ProcessAsync
/// <summary>
/// Processes the provided request asynchronously and returns a response promise.
/// </summary>
/// <param name="request">The request to be handled.</param>
/// <param name="context">The processing context.</param>
/// <param name="token">The cancellation token.</param>
/// <returns>
/// The response promise.
/// </returns>
public Task<IResponse> ProcessAsync(IRequest request, IProcessingContext context, CancellationToken token)
{
Contract.Requires(request != null);
Contract.Requires(context != null);
Contract.Ensures(Contract.Result<Task<IResponse>>() != null);
return Contract.Result<Task<IResponse>>();
}
示例3: EnrichConstructor
public void EnrichConstructor(IProcessingContext context, ConstructorInfo ctor)
{
XmlDocReader reader = this.GetDocReader(ctor.DeclaringType.Assembly);
if (reader != null)
{
XElement element = reader.GetDocComments(ctor);
if (element != null)
this.RewriteXml(context, ctor.ReflectedType.Assembly, element, "param", "typeparam");
}
}
示例4: EnrichType
public void EnrichType(IProcessingContext context, Type type)
{
XmlDocReader reader = this.GetDocReader(type.Assembly);
if (reader != null)
{
XElement element = reader.GetDocComments(type);
if (element != null)
this.RewriteXml(context, type.Assembly, element, "typeparam");
}
}
示例5: EnrichParameter
public void EnrichParameter(IProcessingContext context, ParameterInfo parameter)
{
XmlDocReader reader = this.GetDocReader(context, parameter.Member.ReflectedType.Assembly);
if (reader != null)
{
XElement element = reader.GetDocComments(parameter);
if (element != null)
this.RewriteXmlContent(context, parameter.Member.ReflectedType.Assembly, "summary", element);
}
}
示例6: EnrichParameter
public void EnrichParameter(IProcessingContext context, ParameterInfo parameter)
{
XmlDocReader reader = this.GetDocReader(parameter.Member.DeclaringType.Assembly);
if (reader != null)
{
XNamespace ns = "urn:doc";
XElement element = reader.GetDocComments(parameter);
if (element != null)
this.RewriteXmlContent(context, "summary", element);
}
}
示例7: InstallSecurity
public new void InstallSecurity(string path, IProcessingContext context)
{
Assert.ArgumentNotNullOrEmpty(path, "path");
Assert.ArgumentNotNull((object)context, "context");
Log.Info("Installing security from package: " + path, (object)this);
PackageReader packageReader = new PackageReader(path);
AccountInstaller accountInstaller = new AccountInstaller();
accountInstaller.Initialize(context);
packageReader.Populate((ISink<PackageEntry>)accountInstaller);
accountInstaller.Flush();
accountInstaller.Finish();
}
示例8: GenerateEventElement
private XElement GenerateEventElement(IProcessingContext context, AssetIdentifier assetId)
{
EventInfo eventInfo = (EventInfo)context.AssetResolver.Resolve(assetId);
XElement ret = new XElement("event",
new XAttribute("name", eventInfo.Name),
new XAttribute("assetId", assetId),
new XAttribute("phase", context.Phase));
GenerateTypeRef(context.Clone(ret), eventInfo.EventHandlerType);
MethodInfo addMethod = eventInfo.GetAddMethod(true);
MethodInfo removeMethod = eventInfo.GetRemoveMethod(true);
if (addMethod != null)
{
var addElem = new XElement("add");
if (addMethod.IsPublic)
addElem.Add(new XAttribute("isPublic", XmlConvert.ToString(addMethod.IsPublic)));
if (addMethod.IsPrivate)
addElem.Add(new XAttribute("isPrivate", XmlConvert.ToString(addMethod.IsPrivate)));
if (addMethod.IsFamily)
addElem.Add(new XAttribute("isProtected", XmlConvert.ToString(addMethod.IsFamily)));
ret.Add(addElem);
}
if (removeMethod != null)
{
var removeElem = new XElement("remove");
if (removeMethod.IsPublic)
removeElem.Add(new XAttribute("isPublic", XmlConvert.ToString(removeMethod.IsPublic)));
if (removeMethod.IsPrivate)
removeElem.Add(new XAttribute("isPrivate", XmlConvert.ToString(removeMethod.IsPrivate)));
if (removeMethod.IsFamily)
removeElem.Add(new XAttribute("isProtected", XmlConvert.ToString(removeMethod.IsFamily)));
ret.Add(removeElem);
}
context.Element.Add(ret);
this.GenerateImplementsElement(context.Clone(ret), eventInfo);
foreach (IEnricher item in this.Enrichers)
item.EnrichEvent(context.Clone(ret), eventInfo);
return ret;
}
示例9: GenerateConstructorElement
private XElement GenerateConstructorElement(IProcessingContext context, AssetIdentifier assetId)
{
ConstructorInfo constructorInfo = (ConstructorInfo)context.AssetResolver.Resolve(assetId);
XElement ret = new XElement("constructor",
new XAttribute("assetId", assetId),
new XAttribute("phase", context.Phase));
if (constructorInfo.IsStatic)
ret.Add(new XAttribute("isStatic", XmlConvert.ToString(constructorInfo.IsStatic)));
if (constructorInfo.IsPublic)
ret.Add(new XAttribute("isPublic", XmlConvert.ToString(constructorInfo.IsPublic)));
if (constructorInfo.IsPrivate)
ret.Add(new XAttribute("isPrivate", XmlConvert.ToString(constructorInfo.IsPrivate)));
if (constructorInfo.IsFamily)
ret.Add(new XAttribute("isProtected", XmlConvert.ToString(constructorInfo.IsFamily)));
context.Element.Add(ret);
foreach (IEnricher item in this.Enrichers)
item.EnrichConstructor(context.Clone(ret), constructorInfo);
ParameterInfo[] methodParams = constructorInfo.GetParameters();
this.GenerateParameterElements(context.Clone(ret), methodParams);
return ret;
}
示例10: GenerateImplementsElement
private void GenerateImplementsElement(IProcessingContext context, MemberInfo mInfo)
{
Type declaringType = mInfo.DeclaringType;
if (declaringType.IsGenericType && !declaringType.IsGenericTypeDefinition)
declaringType = declaringType.GetGenericTypeDefinition();
if (!declaringType.IsInterface)
{
Type[] interfaces = declaringType.GetInterfaces();
foreach (Type ifType in interfaces)
{
if (context.IsFiltered(AssetIdentifier.FromMemberInfo(ifType)))
continue;
InterfaceMapping ifMap = declaringType.GetInterfaceMap(ifType);
if (ifMap.TargetType != declaringType)
continue;
var targetMethod =
ifMap.TargetMethods.SingleOrDefault(mi => mi.MetadataToken == mInfo.MetadataToken &&
mi.Module == mInfo.Module);
if (targetMethod != null)
{
int mIx = Array.IndexOf(ifMap.TargetMethods, targetMethod);
AssetIdentifier miAid;
if (ifMap.InterfaceMethods[mIx].DeclaringType.IsGenericType)
{
Type declType = ifMap.InterfaceMethods[mIx].DeclaringType.GetGenericTypeDefinition();
MethodInfo[] allMethods =
declType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |
BindingFlags.Static);
miAid =
AssetIdentifier.FromMemberInfo(allMethods.Single(mi =>
mi.MetadataToken == ifMap.InterfaceMethods[mIx].MetadataToken &&
mi.Module == ifMap.InterfaceMethods[mIx].Module));
}
else
{
miAid = AssetIdentifier.FromMemberInfo(ifMap.InterfaceMethods[mIx]);
}
context.Element.Add(new XElement("implements", new XAttribute("member", miAid)));
context.AddReference(miAid);
}
}
}
}
示例11: GenerateTypeParamElement
private void GenerateTypeParamElement(IProcessingContext context, MemberInfo mInfo, Type tp)
{
// AssetIdentifier assetId = AssetIdentifier.FromType(mInfo, tp);
var tpElem = new XElement("typeparam",
new XAttribute("name", tp.Name));
context.Element.Add(tpElem);
foreach (Type constraint in tp.GetGenericParameterConstraints())
{
var ctElement = new XElement("constraint");
tpElem.Add(ctElement);
GenerateTypeRef(context.Clone(ctElement), constraint);
}
// enrich typeparam
foreach (IEnricher enricher in this.Enrichers)
enricher.EnrichTypeParameter(context.Clone(tpElem), tp);
}
示例12: GenerateNamespaceElement
private XElement GenerateNamespaceElement(IProcessingContext context, AssetIdentifier assetId)
{
string ns = (string)context.AssetResolver.Resolve(assetId);
var ret = new XElement("namespace",
new XAttribute("name", ns),
new XAttribute("assetId", assetId),
new XAttribute("phase", context.Phase));
context.Element.Add(ret);
foreach (IEnricher enricher in this._enrichers)
enricher.EnrichNamespace(context.Clone(ret), ns);
return ret;
}
示例13: GenerateTypeRef
public static void GenerateTypeRef(IProcessingContext context, Type pType, string attrName = null)
{
if (pType.IsArray)
{
var arrayElem = new XElement("arrayOf", new XAttribute("rank", pType.GetArrayRank()));
context.Element.Add(arrayElem);
GenerateTypeRef(context.Clone(arrayElem), pType.GetElementType());
}
else
{
if (pType.IsGenericParameter)
context.Element.Add(new XAttribute("param", pType.Name));
else if (pType.IsGenericType)
{
AssetIdentifier aid = AssetIdentifier.FromType(pType.GetGenericTypeDefinition());
context.AddReference(aid);
context.Element.Add(new XAttribute(attrName ?? "type", aid));
foreach (Type genArg in pType.GetGenericArguments())
{
XElement argElem = new XElement("with");
GenerateTypeRef(context.Clone(argElem), genArg);
context.Element.Add(argElem);
}
}
else
{
AssetIdentifier aid = AssetIdentifier.FromMemberInfo(pType);
context.AddReference(aid);
context.Element.Add(new XAttribute(attrName ?? "type", aid));
}
}
}
示例14: EnrichMethod
public void EnrichMethod(IProcessingContext context, MethodInfo mInfo)
{
GenerateAttributeElements(context, mInfo.GetCustomAttributesData());
}
示例15: RegisterNamespace
public void RegisterNamespace(IProcessingContext context)
{
}