本文整理汇总了C#中IKVM.Reflection.Assembly.__GetCustomAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# Assembly.__GetCustomAttributes方法的具体用法?C# Assembly.__GetCustomAttributes怎么用?C# Assembly.__GetCustomAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IKVM.Reflection.Assembly
的用法示例。
在下文中一共展示了Assembly.__GetCustomAttributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public static AttributeMap[] Create(TypeModel model, Assembly assembly)
{
#if FEAT_IKVM
const bool inherit = false;
System.Collections.Generic.IList<CustomAttributeData> all = assembly.__GetCustomAttributes(model.MapType(typeof(Attribute)), inherit);
AttributeMap[] result = new AttributeMap[all.Count];
int index = 0;
foreach (CustomAttributeData attrib in all)
{
result[index++] = new AttributeDataMap(attrib);
}
return result;
#else
#if WINRT || COREFX
Attribute[] all = System.Linq.Enumerable.ToArray(assembly.GetCustomAttributes());
#else
const bool inherit = false;
object[] all = assembly.GetCustomAttributes(inherit);
#endif
AttributeMap[] result = new AttributeMap[all.Length];
for(int i = 0 ; i < all.Length ; i++)
{
result[i] = new ReflectionAttributeMap((Attribute)all[i]);
}
return result;
#endif
}
示例2: InternalsVisible
bool InternalsVisible(Assembly assembly)
{
#if PHONE8 || SILVERLIGHT || FX11
return false;
#else
if (Helpers.IsNullOrEmpty(assemblyName)) return false;
if (knownTrustedAssemblies != null)
{
if (knownTrustedAssemblies.IndexOfReference(assembly) >= 0)
{
return true;
}
}
if (knownUntrustedAssemblies != null)
{
if (knownUntrustedAssemblies.IndexOfReference(assembly) >= 0)
{
return false;
}
}
bool isTrusted = false;
Type attributeType = MapType(typeof(System.Runtime.CompilerServices.InternalsVisibleToAttribute));
if(attributeType == null) return false;
#if FEAT_IKVM
foreach (CustomAttributeData attrib in assembly.__GetCustomAttributes(attributeType, false))
{
if (attrib.ConstructorArguments.Count == 1)
{
string privelegedAssembly = attrib.ConstructorArguments[0].Value as string;
if (privelegedAssembly == assemblyName)
{
isTrusted = true;
break;
}
}
}
#else
foreach(System.Runtime.CompilerServices.InternalsVisibleToAttribute attrib in assembly.GetCustomAttributes(attributeType, false))
{
if (attrib.AssemblyName == assemblyName)
{
isTrusted = true;
break;
}
}
#endif
if (isTrusted)
{
if (knownTrustedAssemblies == null) knownTrustedAssemblies = new BasicList();
knownTrustedAssemblies.Add(assembly);
}
else
{
if (knownUntrustedAssemblies == null) knownUntrustedAssemblies = new BasicList();
knownUntrustedAssemblies.Add(assembly);
}
return isTrusted;
#endif
}