示例#1
2
        static void GenSchema(string infile, string outdir)
        {
            try
            {
                string text = System.IO.File.ReadAllText(infile);
                Schema schema = Schema.Parse(text);

                CodeGen codegen = new CodeGen();
                codegen.AddSchema(schema);

                codegen.GenerateCode();
                codegen.WriteTypes(outdir);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception occurred. " + ex.Message);
            }
        }
示例#2
0
        static int GenSchema(string infile, string outdir,
                             IEnumerable <KeyValuePair <string, string> > namespaceMapping)
        {
            try
            {
                string text   = System.IO.File.ReadAllText(infile);
                Schema schema = Schema.Parse(text);

                CodeGen codegen = new CodeGen();
                codegen.AddSchema(schema);

                foreach (var entry in namespaceMapping)
                {
                    codegen.NamespaceMapping[entry.Key] = entry.Value;
                }

                codegen.GenerateCode();
                codegen.WriteTypes(outdir);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Exception occurred. " + ex.Message);
                return(1);
            }

            return(0);
        }
示例#3
0
文件: AvroGen.cs 项目: alfhv/avro
        static void GenSchema(List <string> infiles, string outdir,
                              IEnumerable <KeyValuePair <string, string> > namespaceMapping)
        {
            try
            {
                var     sn      = new SchemaNames();
                CodeGen codegen = new CodeGen();
                foreach (var infile in infiles)
                {
                    string text   = System.IO.File.ReadAllText(infile);
                    Schema schema = Schema.Parse(text, sn);
                    codegen.AddSchema(schema);
                }

                foreach (var entry in namespaceMapping)
                {
                    codegen.NamespaceMapping[entry.Key] = entry.Value;
                }

                codegen.GenerateCode();
                codegen.WriteTypes(outdir);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception occurred. " + ex.Message);
            }
        }
        public ValidationResult Validate(string schema)
        {
            try
            {
                var x = new Avro.CodeGen();
                x.AddSchema(Schema.Parse(schema));
                var y = x.GenerateCode();

                return(ValidationResult.Success);
            }
            catch (System.Exception e)
            {
                return(new ValidationResult(e.Message));
            }
        }
示例#5
0
        static void GenSchema(string infile, string outdir)
        {
            try
            {
                var text   = System.IO.File.ReadAllText(infile);
                var schema = Schema.Parse(text);

                var codegen = new CodeGen();
                codegen.AddSchema(schema);

                codegen.GenerateCode();
                codegen.WriteTypes(outdir);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Concat("Exception occurred. ", ex.Message));
            }
        }
示例#6
0
文件: AvroGen.cs 项目: snikhil0/avro
        static void GenSchema(string infile, string outdir)
        {
            try
            {
                string text   = System.IO.File.ReadAllText(infile);
                Schema schema = Schema.Parse(text);

                CodeGen codegen = new CodeGen();
                codegen.AddSchema(schema);

                codegen.GenerateCode();
                codegen.WriteTypes(outdir);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception occurred. " + ex.Message);
            }
        }
示例#7
0
 private static void GenSchema(IEnumerable <string> infile, string outdir)
 {
     try
     {
         var codeGen    = new CodeGen();
         var schemaName = new SchemaNames();
         foreach (var str in infile)
         {
             var schema = Schema.Parse(System.IO.File.ReadAllText(str), schemaName);
             schemaName.Add(schema as NamedSchema);
             codeGen.AddSchema(schema);
         }
         codeGen.GenerateCode();
         codeGen.WriteTypes(outdir);
     }
     catch (Exception exception)
     {
         //Console.WriteLine(string.Concat("Exception occurred. ", exception.Message));
         throw new Exception(string.Concat("Exception occurred. ", exception.Message));
     }
 }
 private void SaveOutProtocals()
 {
     CodeGen cg = new CodeGen();
     foreach (Protocol loaded in Protos.Values)
     {
         cg.AddProtocol(loaded);
         foreach (var s in loaded.Types)
         {
             cg.AddSchema(s);
         }
     }
     foreach (var s in Loaded.Values)
     {
         cg.AddSchema(s);
     }
     cg.GenerateCode();
     string at = @"..\sources\modules\RoboKindAvroQPIDModule\";
     Directory.CreateDirectory(at);
     cg.WriteTypes(at);
 }