本文整理汇总了C#中Mono.Cecil.CustomAttribute.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# CustomAttribute.Resolve方法的具体用法?C# CustomAttribute.Resolve怎么用?C# CustomAttribute.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.CustomAttribute
的用法示例。
在下文中一共展示了CustomAttribute.Resolve方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DomCecilAttribute
/*CustomAttribute customAttribute;
public CustomAttribute CustomAttribute {
get {
return customAttribute;
}
}*/
public DomCecilAttribute (CustomAttribute customAttribute)
{
//this.customAttribute = customAttribute;
base.AttributeType = DomCecilMethod.GetReturnType (customAttribute.Constructor);
base.Name = customAttribute.Constructor.DeclaringType.FullName;
try {
// This Resolve call is required to load enum parameter values.
// Without this call, enum parameters are omited.
customAttribute.Resolve ();
} catch {
// If the resolve operation fails, just continue. The enum parameters will
// be omited, but there will be other parameters
}
foreach (object par in customAttribute.ConstructorParameters)
AddPositionalArgument (new System.CodeDom.CodePrimitiveExpression (par));
foreach (System.Collections.DictionaryEntry entry in customAttribute.Properties)
AddNamedArgument ((string)entry.Key, new System.CodeDom.CodePrimitiveExpression (entry.Value));
foreach (System.Collections.DictionaryEntry entry in customAttribute.Fields)
AddNamedArgument ((string)entry.Key, new System.CodeDom.CodePrimitiveExpression (entry.Value));
}
示例2: WriteCustomAttribute
private void WriteCustomAttribute(CustomAttribute custom)
{
custom.Resolve();
WriteDot();
WriteKeyword("custom");
WriteSpace();
WriteMethodReference(custom.Constructor, true);
WriteSpace();
Write("=");
WriteLine();
if (custom.HasConstructorArguments || custom.HasProperties || custom.HasFields)
{
WriteOpenBreckets();
WriteLine();
Indent();
if (custom.HasConstructorArguments)
{
WriteCustomAttributeConstructorArguments(custom.ConstructorArguments);
}
if (custom.HasProperties)
{
WriteCustomAttributeProperties(custom);
}
if (custom.HasFields)
{
WriteCustomAttributeFields(custom);
}
Outdent();
WriteEndBreckets();
}
else
{
Byte[] blob = custom.GetBlob();
Write("(");
WriteLine();
Indent();
WriteByteArray(blob);
WriteLine();
Outdent();
Write(")");
WriteLine();
}
}
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:44,代码来源:IntermediateLanguageAttributeWriter.cs
示例3: MarkCustomAttribute
void MarkCustomAttribute(CustomAttribute ca)
{
MarkMethod (ca.Constructor);
if (!ca.Resolved) {
ca = ca.Clone ();
ca.Resolve ();
}
if (!ca.Resolved)
return;
MarkCustomAttributeParameters (ca);
TypeReference constructor_type = ca.Constructor.DeclaringType;
TypeDefinition type = constructor_type.Resolve ();
if (type == null)
throw new ResolutionException (constructor_type);
MarkCustomAttributeProperties (ca, type);
MarkCustomAttributeFields (ca, type);
}
示例4: GetCustomAttributeUsedTypes
private static ICollection<TypeReference> GetCustomAttributeUsedTypes(CustomAttribute attribute)
{
List<TypeReference> usedTypes = new List<TypeReference>();
attribute.Resolve();
usedTypes.AddRange(Utilities.GetTypeReferenceTypesDepedningOn(attribute.AttributeType));
for (int argIndex = 0; argIndex < attribute.ConstructorArguments.Count; argIndex++)
{
usedTypes.AddRange(GetAttributeArgumentValueUsedTypes(attribute.ConstructorArguments[argIndex]));
}
if (attribute.HasConstructorArguments || attribute.HasFields || attribute.HasProperties)
{
if (attribute.HasProperties)
{
TypeDefinition attributeType = attribute.AttributeType.Resolve();
usedTypes.AddRange(GetAttributeNamedArgsUsedTypes(attributeType, attribute.Properties, false));
}
if (attribute.HasFields)
{
TypeDefinition attributeType = attribute.AttributeType.Resolve();
usedTypes.AddRange(GetAttributeNamedArgsUsedTypes(attributeType, attribute.Fields, true));
}
}
return usedTypes;
}
示例5: WriteAttribute
protected void WriteAttribute(CustomAttribute attribute, bool skipNewLine = false)
{
if (attributesNotToShow.Contains(attribute.AttributeType.FullName))
{
return;
}
bool resolvingProblem = false;
attribute.Resolve();
genericWriter.WriteToken(OpeningBracket);
resolvingProblem = WriteAttributeSignature(attribute, resolvingProblem);
genericWriter.WriteToken(ClosingBracket);
if (resolvingProblem)
{
genericWriter.Write(" ");
string comment = genericWriter.Language.CommentLines(ASSEMBLYNOTRESOLVEDERROR);
genericWriter.Write(comment.Remove(comment.Length - 2));
}
if (!skipNewLine)
{
genericWriter.WriteLine();
}
}
示例6: WriteGlobalAttribute
private void WriteGlobalAttribute(CustomAttribute attribute, string keyword)
{
if (attributesNotToShow.Contains(attribute.AttributeType.FullName))
{
return;
}
bool resolvingProblem = false;
attribute.Resolve();
genericWriter.WriteToken(OpeningBracket);
genericWriter.WriteKeyword(keyword);
genericWriter.Write(":");
genericWriter.WriteSpace();
resolvingProblem = WriteAttributeSignature(attribute, resolvingProblem);
genericWriter.WriteToken(ClosingBracket);
if (resolvingProblem)
{
genericWriter.Write(" ");
string comment = genericWriter.Language.CommentLines(ASSEMBLYNOTRESOLVEDERROR);
genericWriter.Write(comment.Remove(comment.Length - 2));
}
genericWriter.WriteLine();
}
示例7: GetDynamicPositioningFlags
public static bool[] GetDynamicPositioningFlags(CustomAttribute dynamicAttribute)
{
dynamicAttribute.Resolve();
if (!dynamicAttribute.IsResolved)
{
throw new Exception("Could not resolve DynamicAttribute");
}
if (dynamicAttribute.ConstructorArguments.Count == 0)
{
return new bool[] { true };
}
if (dynamicAttribute.ConstructorArguments[0].Type.FullName != "System.Boolean[]")
{
throw new Exception("Invalid argument type for DynamicAttribute");
}
CustomAttributeArgument[] booleanArray = (CustomAttributeArgument[])dynamicAttribute.ConstructorArguments[0].Value;
bool[] positioningFlags = new bool[booleanArray.Length];
for (int i = 0; i < booleanArray.Length; i++)
{
positioningFlags[i] = (bool)booleanArray[i].Value;
}
return positioningFlags;
}