コード例 #1
0
ファイル: Program.cs プロジェクト: SKProCH/Material.Icons
        static void Main(string[] args)
        {
            var materialIconInfos = MaterialIconsMetaTools.GetIcons().ToList();

            GenerateDataFactory(materialIconInfos);
            GenerateIconKinds(materialIconInfos);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: SKProCH/Material.Icons
        public static void GenerateDataFactory(List <MaterialIconInfo> materialIconInfos)
        {
            var stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("using System;\nusing System.Collections.Generic;\nusing Newtonsoft.Json;\nusing Material.Icons;");
            stringBuilder.AppendLine(
                "namespace Material.Icons\n{\n    /// ******************************************\n    /// This code is auto generated. Do not amend.\n    /// ******************************************");
            stringBuilder.AppendLine(
                "     public static class MaterialIconDataFactory\n    {\n        public static IDictionary<MaterialIconKind, string> DataSetCreate() => new Dictionary<MaterialIconKind, string> {");

            foreach (var info in materialIconInfos)
            {
                stringBuilder.AppendLine($"            {{MaterialIconKind.{info.Name}, \"{info.Data}\"}},");
            }

            stringBuilder.AppendLine(
                "         };\n\n        public static IDictionary<MaterialIconKind, MaterialIconInfo> InstanceSetCreate() => new Dictionary<MaterialIconKind, MaterialIconInfo> {");

            foreach (var info in materialIconInfos)
            {
                stringBuilder.AppendLine($"            {{MaterialIconKind.{info.Name}, {MaterialIconsMetaTools.SerializeIcon(info)}}},");
            }

            stringBuilder.AppendLine("\n        };\n    }\n}");

            File.Delete("MaterialIconDataFactory.cs");
            File.WriteAllText("MaterialIconDataFactory.cs", stringBuilder.ToString());
        }