private static void GetName(CustomAttributeDef ca, out MetadataName name, out MetadataName @namespace)
        {
            var ctor = ca.Constructor;

            if (ctor.IsMemberRef)
            {
                var cls = ctor.MemberRef.Class;
                if (cls.IsTypeRef)
                {
                    name       = cls.TypeRef.TypeName;
                    @namespace = cls.TypeRef.TypeNamespace;
                }
                else
                {
                    name       = cls.TypeDef.Name;
                    @namespace = cls.TypeDef.Namespace;
                }
            }
            else
            {
                var     ctorDef = ctor.MethodDef;
                TypeDef typeDef = ctorDef.FindDeclaringType();
                name       = typeDef.Name;
                @namespace = typeDef.Namespace;
            }
        }
        private static bool IsExtensionAttribute(CustomAttributeDef ca)
        {
            MetadataName name, ns;

            GetName(ca, out name, out ns);
            return(name.Equals(_ExtensionAttributeNameUtf8, 0, _ExtensionAttributeNameUtf8.Length) &&
                   ns.Equals(_ExtensionAttributeNamespaceUtf8, 0, _ExtensionAttributeNamespaceUtf8.Length));
        }
Exemplo n.º 3
0
 private static bool IsExtensionAttribute(CustomAttributeDef ca)
 {
     MetadataName name, ns;
     GetName(ca, out name, out ns);
     return name.Equals(_ExtensionAttributeNameUtf8, 0, _ExtensionAttributeNameUtf8.Length)
         && ns.Equals(_ExtensionAttributeNamespaceUtf8, 0, _ExtensionAttributeNamespaceUtf8.Length);
 }
Exemplo n.º 4
0
 private static void GetName(CustomAttributeDef ca, out MetadataName name, out MetadataName @namespace)
 {
     var ctor = ca.Constructor;
     if (ctor.IsMemberRef) {
         var cls = ctor.MemberRef.Class;
         if (cls.IsTypeRef) {
             name = cls.TypeRef.TypeName;
             @namespace = cls.TypeRef.TypeNamespace;
         } else {
             name = cls.TypeDef.Name;
             @namespace = cls.TypeDef.Namespace;
         }
     } else {
         var ctorDef = ctor.MethodDef;
         TypeDef typeDef = ctorDef.FindDeclaringType();
         name = typeDef.Name;
         @namespace = typeDef.Namespace;
     }
 }