コード例 #1
0
        public static void Generate(string sourceJson)
        {
            ButlerCode bCode = ButlerCodeFactory.Create();

            bCode.Namespace  = "JsonButler.Cli.Payloads";
            bCode.ClassName  = "MyPayload";
            bCode.SourceJson = sourceJson;
            string generatedCode = bCode.Generate();

            ButlerWriterService.SetClipboardText(generatedCode);
        }
コード例 #2
0
        public static void Generate(string sourceJson, string outputFile)
        {
            ButlerCode bCode = ButlerCodeFactory.Create();

            string[] filePathSegments = outputFile.Split('/');
            string   fullFileName     = filePathSegments[filePathSegments.Length - 1];

            string[] fileNameSegments = fullFileName.Split('.');
            string   shortFileName    = fileNameSegments[0];

            bCode.Namespace  = "JsonButler.Cli.Payloads";
            bCode.ClassName  = shortFileName.ToPascalCase();
            bCode.SourceJson = sourceJson;
            string generatedCode = bCode.Generate();

            ButlerWriterService.WriteAllText(outputFile, generatedCode);
        }