예제 #1
0
        public void Test_Parse_And_Generate_Javascript()
        {
            var serviceModel  = FicklefileParserTests.GetTestServiceModel();
            var codeGenerator = ServiceModelCodeGenerator.GetCodeGenerator("javascript", Console.Out, CodeGenerationOptions.Default);

            codeGenerator.Generate(serviceModel);
        }
예제 #2
0
        public void Test_Parse_And_Generate_ObjectiveC()
        {
            var serviceModel = FicklefileParserTests.GetTestServiceModel();

            var codeGenerator = ServiceModelCodeGenerator.GetCodeGenerator("objc", TextWriter.Null, CodeGenerationOptions.Default);

            codeGenerator.Generate(serviceModel);
        }
예제 #3
0
        public void Test_Generate_Objective_To_Console()
        {
            var options = new CodeGenerationOptions
            {
                GenerateClasses = false,
                TypeNamePrefix  = "TN"
            };

            var serviceModel = FicklefileParserTests.GetTestServiceModel();
            var serviceModelcodeGenerator = ServiceModelCodeGenerator.GetCodeGenerator("objc", TextWriter.Null, options);

            serviceModelcodeGenerator.Generate(serviceModel);
        }
예제 #4
0
        public void Test_Generate_CSharp_To_Console()
        {
            var options = new CodeGenerationOptions
            {
                GenerateClasses = true,
                Namespace       = "Io.Fickle.Test.Servicemodel"
            };

            var serviceModel = FicklefileParserTests.GetTestServiceModel();
            var serviceModelcodeGenerator = ServiceModelCodeGenerator.GetCodeGenerator("csharp", TextWriter.Null, options);

            serviceModelcodeGenerator.Generate(serviceModel);
        }
예제 #5
0
        public void Test_Generate_Java_To_Console()
        {
            var options = new CodeGenerationOptions
            {
                GenerateClasses = false,
                TypeNamePrefix  = "TN",
                Namespace       = "io.fickle.test.servicemodel"
            };

            var serviceModel = FicklefileParserTests.GetTestServiceModel();
            var serviceModelcodeGenerator = ServiceModelCodeGenerator.GetCodeGenerator("java", TextWriter.Null, options);

            serviceModelcodeGenerator.Generate(serviceModel);
        }
예제 #6
0
        public void Test_Generate_CSharp_Files()
        {
            var options = new CodeGenerationOptions
            {
                GenerateClasses = true,
                Namespace       = "Io.Fickle.Test.Servicemodel"
            };

            var outputDir    = FileSystemManager.Default.ResolveDirectory("./" + new StackTrace().GetFrame(0).GetMethod().Name);
            var serviceModel = FicklefileParserTests.GetTestServiceModel();

            outputDir.Create(true);

            var serviceModelcodeGenerator = ServiceModelCodeGenerator.GetCodeGenerator("csharp", outputDir, options);

            serviceModelcodeGenerator.Generate(serviceModel);
        }
예제 #7
0
        public void Test_Generate_Javascript_Files()
        {
            var options = new CodeGenerationOptions
            {
                GenerateClasses = false,
                TypeNamePrefix  = "TN"
            };

            var outputDir    = FileSystemManager.Default.ResolveDirectory("./" + new StackTrace().GetFrame(0).GetMethod().Name);
            var serviceModel = FicklefileParserTests.GetTestServiceModel();

            outputDir.Create(true);

            var serviceModelcodeGenerator = ServiceModelCodeGenerator.GetCodeGenerator("javascript", outputDir, options);

            serviceModelcodeGenerator.Generate(serviceModel);
        }
예제 #8
0
        public void Test_Generate_Objective_Files2()
        {
            var options = new CodeGenerationOptions
            {
                GenerateClasses         = true,
                TypeNamePrefix          = "TN",
                SerializeEnumsAsStrings = false
            };

            var outputDir    = FileSystemManager.Default.ResolveDirectory("./" + new StackTrace().GetFrame(0).GetMethod().Name);
            var serviceModel = FicklefileParserTests.GetTestServiceModel2();

            outputDir.Create(true);

            var serviceModelcodeGenerator = ServiceModelCodeGenerator.GetCodeGenerator("objc", outputDir, options);

            serviceModelcodeGenerator.Generate(serviceModel);
        }
예제 #9
0
        public void Test_Generate_CSharp_Files_With_Mapped_Type_Assembly()
        {
            var options = new CodeGenerationOptions
            {
                GenerateClasses      = false,
                GenerateEnums        = false,
                Namespace            = "Io.Fickle.Test.Servicemodel",
                MappedTypeAssemblies = new [] { typeof(Person).Assembly.Location }
            };

            var outputDir    = FileSystemManager.Default.ResolveDirectory("./" + new StackTrace().GetFrame(0).GetMethod().Name);
            var serviceModel = FicklefileParserTests.GetTestServiceModel();

            outputDir.Create(true);

            var serviceModelcodeGenerator = ServiceModelCodeGenerator.GetCodeGenerator("csharp", outputDir, options);

            serviceModelcodeGenerator.Generate(serviceModel);
        }
예제 #10
0
        static int Main(string[] args)
        {
            ServiceModel serviceModel;
            var          options = new CommandLineOptions();

            if (!CommandLine.Parser.Default.ParseArguments(args, options))
            {
                Console.Error.WriteLine("Unable to parse command line arguments");

                return(1);
            }

            if (options.Input == null)
            {
                Console.Error.WriteLine("Must specify input file");

                return(1);
            }

            TextReader textReader = null;

            foreach (var url in options.Input)
            {
                var currentUrl = url;

                if (currentUrl.IndexOf(":", StringComparison.Ordinal) <= 0)
                {
                    currentUrl = "./" + url;
                }

                var reader = FileSystemManager.Default.ResolveFile(currentUrl).GetContent().GetReader(FileShare.Read);

                textReader = textReader == null ? reader : textReader.Concat(reader);
            }

            if (!string.IsNullOrEmpty(options.Output) && options.Output.IndexOf(":", StringComparison.Ordinal) <= 0)
            {
                options.Output = "./" + options.Output;
            }

            using (var reader = textReader)
            {
                serviceModel = FicklefileParser.Parse(reader);
            }

            object outputObject = Console.Out;

            if (!string.IsNullOrEmpty(options.Output))
            {
                var dir = FileSystemManager.Default.ResolveDirectory(options.Output);

                dir.Create(true);

                outputObject = dir;
            }

            var codeGenerationOptions   = new CodeGenerationOptions();
            var defaultServiceModelInfo = codeGenerationOptions.ServiceModelInfo;
            var serviceModelInfo        = new ServiceModelInfo();

            serviceModelInfo.Import(defaultServiceModelInfo);
            serviceModelInfo.Import(serviceModel.ServiceModelInfo);

            if (options.Author != null)
            {
                serviceModelInfo.Author = options.Author;
            }

            if (options.Name != null)
            {
                serviceModelInfo.Name = options.Name;
            }

            if (options.Summary != null)
            {
                serviceModelInfo.Summary = options.Summary;
            }

            if (options.Version != null)
            {
                serviceModelInfo.Version = options.Version;
            }

            if (options.Homepage != null)
            {
                serviceModelInfo.Homepage = options.Homepage;
            }

            if (options.License != null)
            {
                serviceModelInfo.License = options.License;
            }

            if (options.PodspecSource != null)
            {
                serviceModelInfo.ExtendedValues["podspec.source"] = options.PodspecSource;
            }

            if (options.PodspecSourceFiles != null)
            {
                serviceModelInfo.ExtendedValues["podspec.source_files"] = options.PodspecSourceFiles;
            }

            codeGenerationOptions.GeneratePod = options.Pod;
            codeGenerationOptions.ImportDependenciesAsFramework = options.ImportDependenciesAsFramework;
            codeGenerationOptions.ServiceModelInfo = serviceModelInfo;

            using (var codeGenerator = ServiceModelCodeGenerator.GetCodeGenerator(options.Language, outputObject, codeGenerationOptions))
            {
                codeGenerator.Generate(serviceModel);
            }

            return(0);
        }