Beispiel #1
0
        private void GetNamespacesFromCompatAttr(Attribute attr, out string oldXmlns, out string newXmlns)
        {
            XmlnsCompatibleWithAttribute xmlnsCompat = (XmlnsCompatibleWithAttribute)attr;

            oldXmlns = xmlnsCompat.OldNamespace;
            newXmlns = xmlnsCompat.NewNamespace;
        }
        private Dictionary <string, string> LoadOldToNewNs()
        {
            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(XmlnsCompatibleWithAttribute)))
                        {
                            CustomAttributeTypedArgument argument = data.ConstructorArguments[0];
                            string oldns = argument.Value as string;
                            CustomAttributeTypedArgument argument2 = data.ConstructorArguments[1];
                            string newns = argument2.Value as string;
                            this.LoadOldToNewNsHelper(result, oldns, newns, assembly);
                        }
                    }
                    return(result);
                }
                foreach (Attribute attribute in Attribute.GetCustomAttributes(assembly, typeof(XmlnsCompatibleWithAttribute)))
                {
                    XmlnsCompatibleWithAttribute attribute2 = (XmlnsCompatibleWithAttribute)attribute;
                    this.LoadOldToNewNsHelper(result, attribute2.OldNamespace, attribute2.NewNamespace, assembly);
                }
            }
            return(result);
        }
Beispiel #3
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);
        }