本文整理匯總了C#中Mono.CSharp.MetadataImporter.GetCustomAttributeTypeName方法的典型用法代碼示例。如果您正苦於以下問題:C# MetadataImporter.GetCustomAttributeTypeName方法的具體用法?C# MetadataImporter.GetCustomAttributeTypeName怎麽用?C# MetadataImporter.GetCustomAttributeTypeName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mono.CSharp.MetadataImporter
的用法示例。
在下文中一共展示了MetadataImporter.GetCustomAttributeTypeName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ReadAttribute
void ReadAttribute (MetadataImporter importer)
{
IList<CustomAttributeData> cad;
if (provider is MemberInfo) {
cad = CustomAttributeData.GetCustomAttributes ((MemberInfo) provider);
} else if (provider is ParameterInfo) {
cad = CustomAttributeData.GetCustomAttributes ((ParameterInfo) provider);
} else {
provider = null;
return;
}
if (cad.Count > 0) {
string ns, name;
foreach (var ca in cad) {
importer.GetCustomAttributeTypeName (ca, out ns, out name);
if (name != "DynamicAttribute" && ns != CompilerServicesNamespace)
continue;
if (ca.ConstructorArguments.Count == 0) {
flags = single_attribute;
break;
}
var arg_type = ca.ConstructorArguments[0].ArgumentType;
if (arg_type.IsArray && MetaType.GetTypeCode (arg_type.GetElementType ()) == TypeCode.Boolean) {
var carg = (IList<CustomAttributeTypedArgument>) ca.ConstructorArguments[0].Value;
flags = new bool[carg.Count];
for (int i = 0; i < flags.Length; ++i) {
if (MetaType.GetTypeCode (carg[i].ArgumentType) == TypeCode.Boolean)
flags[i] = (bool) carg[i].Value;
}
break;
}
}
}
provider = null;
}
示例2: Read
public static AttributesBag Read (MemberInfo mi, MetadataImporter importer)
{
AttributesBag bag = null;
List<string> conditionals = null;
// It should not throw any loading exception
IList<CustomAttributeData> attrs = CustomAttributeData.GetCustomAttributes (mi);
string ns, name;
foreach (var a in attrs) {
importer.GetCustomAttributeTypeName (a, out ns, out name);
if (name == "ObsoleteAttribute") {
if (ns != "System")
continue;
if (bag == null)
bag = new AttributesBag ();
var args = a.ConstructorArguments;
if (args.Count == 1) {
bag.Obsolete = new ObsoleteAttribute ((string) args[0].Value);
} else if (args.Count == 2) {
bag.Obsolete = new ObsoleteAttribute ((string) args[0].Value, (bool) args[1].Value);
} else {
bag.Obsolete = new ObsoleteAttribute ();
}
continue;
}
if (name == "ConditionalAttribute") {
if (ns != "System.Diagnostics")
continue;
if (bag == null)
bag = new AttributesBag ();
if (conditionals == null)
conditionals = new List<string> (2);
conditionals.Add ((string) a.ConstructorArguments[0].Value);
continue;
}
if (name == "CLSCompliantAttribute") {
if (ns != "System")
continue;
if (bag == null)
bag = new AttributesBag ();
bag.CLSAttributeValue = (bool) a.ConstructorArguments[0].Value;
continue;
}
// Type only attributes
if (mi.MemberType == MemberTypes.TypeInfo || mi.MemberType == MemberTypes.NestedType) {
if (name == "DefaultMemberAttribute") {
if (ns != "System.Reflection")
continue;
if (bag == null)
bag = new AttributesBag ();
bag.DefaultIndexerName = (string) a.ConstructorArguments[0].Value;
continue;
}
if (name == "AttributeUsageAttribute") {
if (ns != "System")
continue;
if (bag == null)
bag = new AttributesBag ();
bag.AttributeUsage = new AttributeUsageAttribute ((AttributeTargets) a.ConstructorArguments[0].Value);
foreach (var named in a.NamedArguments) {
if (named.MemberInfo.Name == "AllowMultiple")
bag.AttributeUsage.AllowMultiple = (bool) named.TypedValue.Value;
else if (named.MemberInfo.Name == "Inherited")
bag.AttributeUsage.Inherited = (bool) named.TypedValue.Value;
}
continue;
}
// Interface only attribute
if (name == "CoClassAttribute") {
if (ns != "System.Runtime.InteropServices")
continue;
if (bag == null)
bag = new AttributesBag ();
bag.CoClass = importer.ImportType ((MetaType) a.ConstructorArguments[0].Value);
continue;
}
}
}
//.........這裏部分代碼省略.........