コード例 #1
0
ファイル: Program.cs プロジェクト: decadestory/Edu
        static void Main(string[] args)
        {
            try
            {
                SonFact.init("server=localhost;database=LLR;uid=sa;pwd=123456Aa;Max Pool Size=1000");

                Console.WriteLine("=====================");
                Console.WriteLine("Generator Start...");
                Console.WriteLine("=====================");

                GeneratorCore.Generate("TrainLearner");

                Console.WriteLine("=====================");
                Console.WriteLine("Generator Success!");
                Console.WriteLine("=====================");
                Console.WriteLine("Press Any Key To Exit!");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Generator Error:" + ex.Message);
            }
            finally
            {
                Console.ReadKey();
            }
        }
        public static IEnumerable <string> GenerateCode(string jsonSchema, string defaultNamespace, bool namespaceIsForced)
        {
            var sources = new List <string>();

            IEnumerable <TypeSchema> schemas = Utils.CodeGenerator.ResolveCodeGeneratingSchemas(jsonSchema);

            foreach (TypeSchema schema in schemas)
            {
                using (var memoryStream = new MemoryStream())
                {
                    GeneratorCore.Generate(schema, defaultNamespace, namespaceIsForced, memoryStream);
                    memoryStream.Flush();
                    var reader = new StreamReader(memoryStream, new UTF8Encoding());
                    memoryStream.Seek(0, SeekOrigin.Begin);
                    sources.Add(reader.ReadToEnd());
                }
            }

            return(sources);
        }