当前位置: 首页>>代码示例>>C#>>正文


C# Assembly.__GetCustomAttributes方法代码示例

本文整理汇总了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
        }
开发者ID:GeorchW,项目名称:protobuf-net,代码行数:28,代码来源:AttributeMap.cs

示例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
 }
开发者ID:banksyhf,项目名称:Auxilium-2,代码行数:59,代码来源:CompilerContext.cs


注:本文中的IKVM.Reflection.Assembly.__GetCustomAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。