Пример #1
0
        public static XmlNode CreateNode(Type type, XmlDocument doc)
        {
            ITypeNodeBuilder builder;

            if (type.IsClass == true && type.IsSubclassOf(typeof(MulticastDelegate)) == false)
            {
                builder = new classNodeBuilder();
            }
            else if (type.IsClass == true && type.IsSubclassOf(typeof(MulticastDelegate)) == true)
            {
                builder = new delegateNodeBuilder();
            }
            else if (type.IsEnum)
            {
                builder = new enumNodeBuilder();
            }
            else if (type.IsInterface)
            {
                builder = new interfaceNodeBuilder();
            }
            else if (type.IsValueType == true)
            {
                builder = new structNodeBuilder();
            }
            else
            {
                throw new Exception("Generation for this type is currently not supported: " + type.Name);
            }

            return(builder.buildNode(doc, type));
        }
Пример #2
0
		public static XmlNode CreateNode(Type type, XmlDocument doc)
		{
			ITypeNodeBuilder builder;
			
			if(type.IsClass == true && type.IsSubclassOf(typeof(MulticastDelegate)) == false) {
				builder = new classNodeBuilder();
			} else if(type.IsClass == true && type.IsSubclassOf(typeof(MulticastDelegate)) == true) {
				builder = new delegateNodeBuilder();
			} else if(type.IsEnum) {
				builder = new enumNodeBuilder();
			} else if(type.IsInterface) {
				builder = new interfaceNodeBuilder();
			} else if(type.IsValueType == true) {
				builder = new structNodeBuilder();
			} else {
				throw new Exception("Generation for this type is currently not supported: " + type.Name);
			}
			
			return builder.buildNode(doc, type);
		}
Пример #3
0
		public Generator(XmlDocument doc, XmlNode rootNode, string[] args)
		{
			AssemblyLoader loader = new AssemblyLoader();
			Assembly[] assemblies;
			
			try {
				assemblies = loader.LoadAssemblies(args);
			} catch(Exception e) {
				throw e;
			}
					
			Hashtable typesByNamespace = loadTypesByNamespace(assemblies);
			
			string[] namespacesSorted = new string[typesByNamespace.Keys.Count];
			int count = 0;
			
			foreach(string nspace in typesByNamespace.Keys) {
				namespacesSorted[count] = nspace;
				count++;
			}
			
			Array.Sort(namespacesSorted);
			
			foreach(string nspace in namespacesSorted) {
				// create folder node for namespace
				XmlNode namespaceNode = doc.CreateElement("HelpFolder");
				XmlAttribute attrib = doc.CreateAttribute("name");
				attrib.Value = nspace;
				
				
				namespaceNode.Attributes.Append(attrib);
				
				string[] typesSorted = new string[((Hashtable)typesByNamespace[nspace]).Count];
				count = 0;
				
				foreach(string typeName in ((Hashtable)typesByNamespace[nspace]).Keys) {
					typesSorted[count] = typeName;
					count++;
				}
				
				Array.Sort(typesSorted);
				
				// put the namespace in a separate file
				XmlDocument newDoc = new XmlDocument();
				newDoc.LoadXml("<HelpCollection/>");
				bool setNamespaceLink = false;
				foreach(string typeName in typesSorted) {
					Type type = (Type)((Hashtable)typesByNamespace[nspace])[typeName];
					try {
						newDoc.DocumentElement.AppendChild(TypeNodeFactory.CreateNode(type, newDoc));
						// set link to namespace description
						if (!setNamespaceLink) {
							classNodeBuilder cbn = new classNodeBuilder();
							cbn.SetLink(doc, namespaceNode, cbn.ConvertLink(classNodeBuilder.helpFileFormat.NamespaceFormat,type ));	
							setNamespaceLink = true;
						}
					} catch(Exception e) {
						System.Console.WriteLine(e.Message);
					}
				}
				string helpFileName = Application.StartupPath + Path.DirectorySeparatorChar + nspace + "Help.xml";
				HelpBrowserApp.HelpFiles.Add(helpFileName);
				newDoc.Save(helpFileName);
				
				// create help reference
				XmlElement referenceNode = doc.CreateElement("HelpReference");
				attrib = doc.CreateAttribute("reference");
				attrib.Value = nspace + "Help.xml";
				referenceNode.Attributes.Append(attrib);
				namespaceNode.AppendChild(referenceNode);
				
				// add the namespace + reference node to the document
				rootNode.AppendChild(namespaceNode);
			}
		}
Пример #4
0
        public Generator(XmlDocument doc, XmlNode rootNode, string[] args)
        {
            AssemblyLoader loader = new AssemblyLoader();

            Assembly[] assemblies;

            try {
                assemblies = loader.LoadAssemblies(args);
            } catch (Exception e) {
                throw e;
            }

            Hashtable typesByNamespace = loadTypesByNamespace(assemblies);

            string[] namespacesSorted = new string[typesByNamespace.Keys.Count];
            int      count            = 0;

            foreach (string nspace in typesByNamespace.Keys)
            {
                namespacesSorted[count] = nspace;
                count++;
            }

            Array.Sort(namespacesSorted);

            foreach (string nspace in namespacesSorted)
            {
                // create folder node for namespace
                XmlNode      namespaceNode = doc.CreateElement("HelpFolder");
                XmlAttribute attrib        = doc.CreateAttribute("name");
                attrib.Value = nspace;


                namespaceNode.Attributes.Append(attrib);

                string[] typesSorted = new string[((Hashtable)typesByNamespace[nspace]).Count];
                count = 0;

                foreach (string typeName in ((Hashtable)typesByNamespace[nspace]).Keys)
                {
                    typesSorted[count] = typeName;
                    count++;
                }

                Array.Sort(typesSorted);

                // put the namespace in a separate file
                XmlDocument newDoc = new XmlDocument();
                newDoc.LoadXml("<HelpCollection/>");
                bool setNamespaceLink = false;
                foreach (string typeName in typesSorted)
                {
                    Type type = (Type)((Hashtable)typesByNamespace[nspace])[typeName];
                    try {
                        newDoc.DocumentElement.AppendChild(TypeNodeFactory.CreateNode(type, newDoc));
                        // set link to namespace description
                        if (!setNamespaceLink)
                        {
                            classNodeBuilder cbn = new classNodeBuilder();
                            cbn.SetLink(doc, namespaceNode, cbn.ConvertLink(classNodeBuilder.helpFileFormat.NamespaceFormat, type));
                            setNamespaceLink = true;
                        }
                    } catch (Exception e) {
                        System.Console.WriteLine(e.Message);
                    }
                }
                string helpFileName = Application.StartupPath + Path.DirectorySeparatorChar + nspace + "Help.xml";
                HelpBrowserApp.HelpFiles.Add(helpFileName);
                newDoc.Save(helpFileName);

                // create help reference
                XmlElement referenceNode = doc.CreateElement("HelpReference");
                attrib       = doc.CreateAttribute("reference");
                attrib.Value = nspace + "Help.xml";
                referenceNode.Attributes.Append(attrib);
                namespaceNode.AppendChild(referenceNode);

                // add the namespace + reference node to the document
                rootNode.AppendChild(namespaceNode);
            }
        }