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);
        }
Пример #2
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);
        }