コード例 #1
0
        private static void WriteDocumentation(string documentationFilePath, SettingsMetaData settings)
        {
            XmlDocument doc = new XmlDocument();

            doc.AppendChild(doc.CreateComment(" THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT MODIFY. "));

            XmlNode root = doc.AppendChild(Helper.CreateElement(doc, "Documentation"));

            {
                RC.WriteLine(ConsoleThemeColor.TitleText, " - " + "NoItemSelectedText");

                XmlElement metaNode = Helper.CreateElement(doc, "NoItemSelectedText");

                metaNode.InnerText = settings.NoItemSelectedText;

                root.AppendChild(metaNode);
            }

            foreach (SettingValue meta in settings.AllVariables)
            {
                RC.WriteLine(ConsoleThemeColor.TitleText, " - " + meta.OscAddress);

                XmlElement metaNode = Helper.CreateElement(doc, "Setting");

                Helper.AppendAttributeAndValue(metaNode, "Address", meta.OscAddress);

                metaNode.InnerText = meta.DocumentationBody;

                root.AppendChild(metaNode);
            }

            doc.Save(documentationFilePath);
        }
コード例 #2
0
        private static void Generate(string xmlFilePath, string codeFilePath, string documentationFilePath)
        {
            RC.WriteLine(ConsoleThemeColor.TitleText, "Reading XML File");

            XmlDocument doc = new XmlDocument();

            doc.Load(xmlFilePath);

            SettingsMetaData settings = new SettingsMetaData(doc);

            FileTemplate     = File.ReadAllText(Helper.ResolvePath("~/Templates/FileTemplate.txt"));
            CategoryTemplate = File.ReadAllText(Helper.ResolvePath("~/Templates/CategoryTemplate.txt"));
            SettingsTemplate = File.ReadAllText(Helper.ResolvePath("~/Templates/SettingsTemplate.txt"));

            List <string> groupTypesDefinitions = new List <string>();

            string settingsTypeDefinition = GenerateSettingsType(settings, ref groupTypesDefinitions);

            string final = FileTemplate
                           .Replace("[$RootCategory]", PrefixLines(new string[] { settingsTypeDefinition }, '\t', 1))
                           .Replace("[$CategoryClasses]", PrefixLines(groupTypesDefinitions, '\t', 2));

            RC.WriteLine(ConsoleThemeColor.TitleText, "Writing: " + codeFilePath);
            File.WriteAllText(codeFilePath, final);

            RC.WriteLine(ConsoleThemeColor.TitleText, "Writing: " + documentationFilePath);

            WriteDocumentation(documentationFilePath, settings);
        }
コード例 #3
0
        private static string GenerateSettingsType(SettingsMetaData settings, ref List <string> groupTypesDefinitions)
        {
            Dictionary <string, string> replacements = new Dictionary <string, string>();

            GenerateMembers(settings, true, groupTypesDefinitions, replacements, "Settings");

            return(DoReplacements(replacements, SettingsTemplate));
        }