private ICollection <AssemblyName> LoadInternalsVisibleTo()
        {
            List <AssemblyName> result = new List <AssemblyName>();

            System.Reflection.Assembly assembly = this.Assembly;
            if (assembly != null)
            {
                if (assembly.ReflectionOnly)
                {
                    this.EnsureReflectionOnlyAttributeData();
                    foreach (CustomAttributeData data in this._attributeData)
                    {
                        if (LooseTypeExtensions.AssemblyQualifiedNameEquals(data.Constructor.DeclaringType, typeof(InternalsVisibleToAttribute)))
                        {
                            CustomAttributeTypedArgument argument = data.ConstructorArguments[0];
                            string assemblyName = argument.Value as string;
                            this.LoadInternalsVisibleToHelper(result, assemblyName, assembly);
                        }
                    }
                    return(result);
                }
                foreach (InternalsVisibleToAttribute attribute in Attribute.GetCustomAttributes(assembly, typeof(InternalsVisibleToAttribute)))
                {
                    this.LoadInternalsVisibleToHelper(result, attribute.AssemblyName, assembly);
                }
            }
            return(result);
        }
        private Dictionary <string, string> LoadPrefixes()
        {
            Dictionary <string, string> result = new Dictionary <string, string>(StringComparer.Ordinal);

            System.Reflection.Assembly assembly = this.Assembly;
            if (assembly != null)
            {
                if (assembly.ReflectionOnly)
                {
                    this.EnsureReflectionOnlyAttributeData();
                    foreach (CustomAttributeData data in this._attributeData)
                    {
                        if (LooseTypeExtensions.AssemblyQualifiedNameEquals(data.Constructor.DeclaringType, typeof(XmlnsPrefixAttribute)))
                        {
                            CustomAttributeTypedArgument argument = data.ConstructorArguments[0];
                            string xmlns = argument.Value as string;
                            CustomAttributeTypedArgument argument2 = data.ConstructorArguments[1];
                            string prefix = argument2.Value as string;
                            this.LoadPrefixesHelper(result, xmlns, prefix, assembly);
                        }
                    }
                    return(result);
                }
                foreach (Attribute attribute in Attribute.GetCustomAttributes(assembly, typeof(XmlnsPrefixAttribute)))
                {
                    XmlnsPrefixAttribute attribute2 = (XmlnsPrefixAttribute)attribute;
                    this.LoadPrefixesHelper(result, attribute2.XmlNamespace, attribute2.Prefix, assembly);
                }
            }
            return(result);
        }
 private string LoadRootNamespace()
 {
     System.Reflection.Assembly element = this.Assembly;
     if (element != null)
     {
         if (element.ReflectionOnly)
         {
             this.EnsureReflectionOnlyAttributeData();
             foreach (CustomAttributeData data in this._attributeData)
             {
                 if (LooseTypeExtensions.AssemblyQualifiedNameEquals(data.Constructor.DeclaringType, typeof(RootNamespaceAttribute)))
                 {
                     CustomAttributeTypedArgument argument = data.ConstructorArguments[0];
                     return(argument.Value as string);
                 }
             }
             return(null);
         }
         RootNamespaceAttribute customAttribute = (RootNamespaceAttribute)Attribute.GetCustomAttribute(element, typeof(RootNamespaceAttribute));
         if (customAttribute != null)
         {
             return(customAttribute.Namespace);
         }
     }
     return(null);
 }
示例#4
0
        string LoadRootNamespace()
        {
            Assembly assembly = Assembly;

            if (assembly == null)
            {
                return(null);
            }
            if (assembly.ReflectionOnly)
            {
                EnsureReflectionOnlyAttributeData();

                foreach (var cad in _attributeData)
                {
                    if (LooseTypeExtensions.AssemblyQualifiedNameEquals(cad.Constructor.DeclaringType, typeof(RootNamespaceAttribute)))
                    {
                        return(cad.ConstructorArguments[0].Value as string);
                    }
                }
                return(null);
            }
            else
            {
                RootNamespaceAttribute rootNs = (RootNamespaceAttribute)
                                                Attribute.GetCustomAttribute(assembly, typeof(RootNamespaceAttribute));
                return((rootNs == null) ? null : rootNs.Namespace);
            }
        }
        private IList <XmlNsDefinition> LoadNsDefs()
        {
            IList <XmlNsDefinition> result = new List <XmlNsDefinition>();

            System.Reflection.Assembly assembly = this.Assembly;
            if (assembly != null)
            {
                if (assembly.ReflectionOnly)
                {
                    this.EnsureReflectionOnlyAttributeData();
                    foreach (CustomAttributeData data in this._attributeData)
                    {
                        if (LooseTypeExtensions.AssemblyQualifiedNameEquals(data.Constructor.DeclaringType, typeof(XmlnsDefinitionAttribute)))
                        {
                            CustomAttributeTypedArgument argument = data.ConstructorArguments[0];
                            string xmlns = argument.Value as string;
                            CustomAttributeTypedArgument argument2 = data.ConstructorArguments[1];
                            string clrns = argument2.Value as string;
                            this.LoadNsDefHelper(result, xmlns, clrns, assembly);
                        }
                    }
                    return(result);
                }
                foreach (Attribute attribute in Attribute.GetCustomAttributes(assembly, typeof(XmlnsDefinitionAttribute)))
                {
                    XmlnsDefinitionAttribute attribute2 = (XmlnsDefinitionAttribute)attribute;
                    string xmlNamespace = attribute2.XmlNamespace;
                    string clrNamespace = attribute2.ClrNamespace;
                    this.LoadNsDefHelper(result, xmlNamespace, clrNamespace, assembly);
                }
            }
            return(result);
        }
示例#6
0
        Dictionary <string, string> LoadPrefixes()
        {
            Dictionary <string, string> result = new Dictionary <string, string>(StringComparer.Ordinal);

            Assembly assembly = Assembly;

            if (assembly == null)
            {
                return(result);
            }
            if (assembly.ReflectionOnly)
            {
                EnsureReflectionOnlyAttributeData();

                foreach (var cad in _attributeData)
                {
                    if (LooseTypeExtensions.AssemblyQualifiedNameEquals(cad.Constructor.DeclaringType, typeof(XmlnsPrefixAttribute)))
                    {
                        string xmlns  = cad.ConstructorArguments[0].Value as string;
                        string prefix = cad.ConstructorArguments[1].Value as string;
                        LoadPrefixesHelper(result, xmlns, prefix, assembly);
                    }
                }
            }
            else
            {
                Attribute[] attributes = Attribute.GetCustomAttributes(assembly, typeof(XmlnsPrefixAttribute));
                foreach (Attribute attr in attributes)
                {
                    XmlnsPrefixAttribute xmlnsPrefixAttr = (XmlnsPrefixAttribute)attr;
                    LoadPrefixesHelper(result, xmlnsPrefixAttr.XmlNamespace, xmlnsPrefixAttr.Prefix, assembly);
                }
            }
            return(result);
        }
示例#7
0
        ICollection <AssemblyName> LoadInternalsVisibleTo()
        {
            var result = new List <AssemblyName>();

            Assembly assembly = Assembly;

            if (assembly == null)
            {
                return(result);
            }
            if (assembly.ReflectionOnly)
            {
                EnsureReflectionOnlyAttributeData();
                foreach (var cad in _attributeData)
                {
                    if (LooseTypeExtensions.AssemblyQualifiedNameEquals(cad.Constructor.DeclaringType, typeof(InternalsVisibleToAttribute)))
                    {
                        string assemblyName = cad.ConstructorArguments[0].Value as string;
                        LoadInternalsVisibleToHelper(result, assemblyName, assembly);
                    }
                }
            }
            else
            {
                Attribute[] attributes = Attribute.GetCustomAttributes(assembly, typeof(InternalsVisibleToAttribute));
                for (int i = 0; i < attributes.Length; i++)
                {
                    InternalsVisibleToAttribute ivAttrib = (InternalsVisibleToAttribute)attributes[i];
                    LoadInternalsVisibleToHelper(result, ivAttrib.AssemblyName, assembly);
                }
            }
            return(result);
        }
示例#8
0
 private static bool TypesAreEqual(Type userType, Type builtInType)
 {
     if (userType.Assembly.ReflectionOnly)
     {
         return(LooseTypeExtensions.AssemblyQualifiedNameEquals(userType, builtInType));
     }
     return(userType == builtInType);
 }
示例#9
0
        IList <XmlNsDefinition> LoadNsDefs()
        {
            IList <XmlNsDefinition> result = new List <XmlNsDefinition>();

            Assembly assembly = Assembly;

            if (assembly == null)
            {
                return(result);
            }
            if (assembly.ReflectionOnly)
            {
                EnsureReflectionOnlyAttributeData();
                foreach (var cad in _attributeData)
                {
                    if (LooseTypeExtensions.AssemblyQualifiedNameEquals(cad.Constructor.DeclaringType, typeof(XmlnsDefinitionAttribute)))
                    {
                        // WPF 3.0 ignores XmlnsDefinitionAttribute.AssemblyName, and so do we
                        string xmlns = cad.ConstructorArguments[0].Value as string;
                        string clrns = cad.ConstructorArguments[1].Value as string;
                        LoadNsDefHelper(result, xmlns, clrns, assembly);
                    }
                }
            }
            else
            {
                Attribute[] attributes;
                attributes = Attribute.GetCustomAttributes(assembly, typeof(XmlnsDefinitionAttribute));
                foreach (Attribute attr in attributes)
                {
                    XmlnsDefinitionAttribute xmlnsDefAttr = (XmlnsDefinitionAttribute)attr;

                    string xmlns = xmlnsDefAttr.XmlNamespace;
                    string clrns = xmlnsDefAttr.ClrNamespace;
                    LoadNsDefHelper(result, xmlns, clrns, assembly);
                }
            }
            return(result);
        }
示例#10
0
        Dictionary <string, string> LoadOldToNewNs()
        {
            Dictionary <string, string> result = new Dictionary <string, string>(StringComparer.Ordinal);

            Assembly assembly = Assembly;

            if (assembly == null)
            {
                return(result);
            }
            if (assembly.ReflectionOnly)
            {
                EnsureReflectionOnlyAttributeData();

                foreach (var cad in _attributeData)
                {
                    if (LooseTypeExtensions.AssemblyQualifiedNameEquals(cad.Constructor.DeclaringType, typeof(XmlnsCompatibleWithAttribute)))
                    {
                        string oldns = cad.ConstructorArguments[0].Value as string;
                        string newns = cad.ConstructorArguments[1].Value as string;
                        LoadOldToNewNsHelper(result, oldns, newns, assembly);
                    }
                }
            }
            else
            {
                Attribute[] attributes = Attribute.GetCustomAttributes(assembly, typeof(XmlnsCompatibleWithAttribute));
                foreach (Attribute attr in attributes)
                {
                    // Read in the attribute value
                    XmlnsCompatibleWithAttribute xmlnsCompatAttr = (XmlnsCompatibleWithAttribute)attr;
                    LoadOldToNewNsHelper(result, xmlnsCompatAttr.OldNamespace, xmlnsCompatAttr.NewNamespace, assembly);
                }
            }

            return(result);
        }