本文整理匯總了C#中Mono.Cecil.ParameterDefinition.TryGetDynamicAttribute方法的典型用法代碼示例。如果您正苦於以下問題:C# ParameterDefinition.TryGetDynamicAttribute方法的具體用法?C# ParameterDefinition.TryGetDynamicAttribute怎麽用?C# ParameterDefinition.TryGetDynamicAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mono.Cecil.ParameterDefinition
的用法示例。
在下文中一共展示了ParameterDefinition.TryGetDynamicAttribute方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CheckParameter
private bool CheckParameter(ParameterDefinition paramDef)
{
CustomAttribute dynamicAttribute;
if(!paramDef.TryGetDynamicAttribute(out dynamicAttribute))
{
return false;
}
bool[] dynamicPositioningFlags = DynamicHelper.GetDynamicPositioningFlags(dynamicAttribute);
if(dynamicPositioningFlags.Length != this.dynamicPositioningFlags.Count)
{
return false;
}
LinkedListNode<bool> currentNode = this.dynamicPositioningFlags.First;
foreach (bool flag in dynamicPositioningFlags)
{
if(flag != currentNode.Value)
{
return false;
}
currentNode = currentNode.Next;
}
return true;
}
示例2: DoWriteParameterTypeAndName
protected override void DoWriteParameterTypeAndName(TypeReference type, string name, ParameterDefinition reference)
{
if (!Language.IsValidIdentifier(name))
{
name = Language.ReplaceInvalidCharactersInIdentifier(name);
}
if (reference.IsParamArray())
{
WriteKeyword(KeyWordWriter.ParamArray);
WriteSpace();
}
CustomAttribute dynamicAttribute;
if (reference.TryGetDynamicAttribute(out dynamicAttribute))
{
IEnumerator positioningFlagsEnumerator = DynamicHelper.GetDynamicPositioningFlags(dynamicAttribute).GetEnumerator();
if (reference.ParameterType.IsByReference && (reference.ParameterType as ByReferenceType).ElementType == type)
{
if (!positioningFlagsEnumerator.MoveNext() || (bool)positioningFlagsEnumerator.Current)
{
throw new Exception("Invalid argument type for DynamicAttribute");
}
}
WriteDynamicType(type, positioningFlagsEnumerator);
WriteSpace();
}
else
{
// undocumented C# keyword like __arglist
if (!string.IsNullOrEmpty(ToTypeString(type)))
{
WriteReferenceAndNamespaceIfInCollision(type);
WriteSpace();
}
}
if (Language.IsGlobalKeyword(name))
{
name = Utilities.EscapeName(name, this.Language);
}
Write(name);
}