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); } }
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); }
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)); } }
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)); } }
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); }