public string Generate(MahuaApiCommandInfo mahuaApiCommandInfo)
        {
            var dirPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                       "ItemTemplate",
                                       "ApiCommandHandler");
            var dir = new DirectoryInfo(dirPath);

            if (!dir.Exists)
            {
                Directory.CreateDirectory(dir.FullName);
                Thread.Sleep(100);
            }

            var mahuaEventCs = new MahuaApiCommandHandlerCS
            {
                Session = new Dictionary <string, object>
                {
                    ["Des"] = mahuaApiCommandInfo
                }
            };

            mahuaEventCs.Initialize();
            var cs        = mahuaEventCs.TransformText();
            var className = mahuaApiCommandInfo.CommandHandlerName;

            WriteFileWithUtf8Bom(cs, Path.Combine(dirPath, $"{className}.cs"), true);

            return($"{className}.cs");
        }
        public MahuaApiCommandInfo Resolve(Type cmdType)
        {
            var description = ((DescriptionAttribute)cmdType.GetCustomAttribute(typeof(DescriptionAttribute))).Description;
            var re          = new MahuaApiCommandInfo
            {
                Summary            = description,
                CommandName        = cmdType.Name,
                CommandResultName  = typeof(ApiMahuaCommand).IsAssignableFrom(cmdType) ? string.Empty : $"{cmdType.Name}Result",
                CommandHandlerName = $"{cmdType.Name}Handler"
            };

            return(re);
        }
        public string Generate(MahuaApiCommandInfo mahuaApiCommandInfo)
        {
            var className = mahuaApiCommandInfo.CommandHandlerName;
            var dirPath   = Path.Combine(
                AppDomain.CurrentDomain.BaseDirectory,
                className);
            var dir = new DirectoryInfo(dirPath);

            if (dir.Exists)
            {
                dir.Delete(true);
                Thread.Sleep(100);
            }
            Directory.CreateDirectory(dir.FullName);

            var mahuaEventCs = new MahuaApiCommandHandlerCS
            {
                Session = new Dictionary <string, object>
                {
                    ["Des"] = mahuaApiCommandInfo
                }
            };

            mahuaEventCs.Initialize();
            var cs = mahuaEventCs.TransformText();

            WriteFileWithUtf8Bom(cs, Path.Combine(dirPath, $"{className}.cs"), true);


            var mahuaEventMyTemplateXml = new MahuaApiCommandHandlerMyTemplateXml
            {
                Session = new Dictionary <string, object>
                {
                    ["Des"] = mahuaApiCommandInfo
                }
            };

            mahuaEventMyTemplateXml.Initialize();
            var xml = mahuaEventMyTemplateXml.TransformText();

            WriteFileWithUtf8Bom(xml, Path.Combine(dirPath, "MyTemplate.vstemplate"), false);

            File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logo.png"), Path.Combine(dirPath, "__TemplateIcon.png"));
            File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logo.png"), Path.Combine(dirPath, "__PreviewImage.png"));

            Process.Start("7z.exe", $"a {className}.zip .\\{className}\\*");
            return($"{className}.zip");
        }