Beispiel #1
0
        private static string GetClassName(
            XmlQualifiedName[] namespaces, NamedMetadata nodeType,
            Dictionary <string, string> domNodeTypeToClassName,
            Dictionary <string, string> classNameToDomNodeType)
        {
            // Remove the namespace decoration, including the ':'.
            string className = nodeType.Name;

            foreach (XmlQualifiedName xmlName in namespaces)
            {
                if (className.StartsWith(xmlName.Namespace) &&
                    className.Length > xmlName.Namespace.Length &&
                    className[xmlName.Namespace.Length] == ':')
                {
                    className = className.Substring(xmlName.Namespace.Length + 1);
                    break;
                }
            }

            className = CreateIdentifier(className);

            // If we've already seen this class name, revert to the version with the namespace prepended, otherwise
            //  the *.cs file created won't compile.
            if (classNameToDomNodeType.ContainsKey(className))
            {
                className = CreateIdentifier(nodeType.Name);
            }

            domNodeTypeToClassName[nodeType.Name] = className;
            classNameToDomNodeType[className]     = nodeType.Name;

            return(className);
        }
Beispiel #2
0
        private static string GetClassName(
            XmlQualifiedName[] namespaces, NamedMetadata nodeType,
            Dictionary<string,string> domNodeTypeToClassName,
            Dictionary<string,string> classNameToDomNodeType)
        {
            // Remove the namespace decoration, including the ':'.
            string className = nodeType.Name;
            foreach (XmlQualifiedName xmlName in namespaces)
            {
                if (className.StartsWith(xmlName.Namespace) &&
                    className.Length > xmlName.Namespace.Length &&
                    className[xmlName.Namespace.Length] == ':')
                {
                    className = className.Substring(xmlName.Namespace.Length + 1);
                    break;
                }
            }

            className = CreateIdentifier(className);

            // If we've already seen this class name, revert to the version with the namespace prepended, otherwise
            //  the *.cs file created won't compile.
            if (classNameToDomNodeType.ContainsKey(className))
                className = CreateIdentifier(nodeType.Name);

            domNodeTypeToClassName[nodeType.Name] = className;
            classNameToDomNodeType[className] = nodeType.Name;

            return className;
        }