Пример #1
0
        public void HandshakeResponse_avsc()
        {
            const string PREFIX = "Simple_avpr() - ";
            const string inputFile = "CodeGen/HandshakeResponse.avsc";
            string outputFile = Path.GetFullPath(inputFile);
            outputFile = Path.ChangeExtension(inputFile, ".cs");
            Schema schema = loadSchemaFromFile(inputFile);

            AvroGen generator = new AvroGen();
            generator.Types.Add(schema);

            CodeCompileUnit cu = generate(generator);

            writeSource(outputFile, cu);

            CompilerParameters parms = new CompilerParameters();
            parms.ReferencedAssemblies.Add(typeof(Schema).Assembly.Location);
            parms.ReferencedAssemblies.Add(typeof(System.CodeDom.Compiler.GeneratedCodeAttribute).Assembly.Location);
            CompilerResults results = csp.CompileAssemblyFromDom(parms, cu);

            foreach (CompilerError error in results.Errors)
            {
                if (log.IsErrorEnabled) log.ErrorFormat(PREFIX + "{0}", error);
            }
            Assert.IsTrue(results.Errors.Count == 0, "Errors were encountered.");

        }
Пример #2
0
        public void wordcount_avsc()
        {
            const string inputFile = "CodeGen/WordCount.avsc";
            string outputFile = Path.GetFullPath(inputFile);
            outputFile = Path.ChangeExtension(inputFile, ".cs");
            Schema schema = loadSchemaFromFile(inputFile);

            AvroGen generator = new AvroGen();
            generator.Types.Add(schema);

            CodeCompileUnit cu = generate(generator);

            writeSource(outputFile, cu);
        }
Пример #3
0
 private static CodeCompileUnit generate(AvroGen generator)
 {
     CodeCompileUnit cu = generator.GenerateClient();
     Assert.IsNotNull(cu);
     Assert.IsTrue(cu.Namespaces.Count > 0, "Some namespaces should have been generated.");
     return cu;
 }
Пример #4
0
        public void namespace_avpr()
        {
            const string inputFile = "CodeGen/namespace.avpr";
            string outputFile = Path.GetFullPath(inputFile);
            outputFile = Path.ChangeExtension(inputFile, ".cs");
            Protocol protocol = loadProtocolFromFile(inputFile);

            AvroGen generator = new AvroGen();
            generator.Protocols.Add(protocol);

            CodeCompileUnit cu = generate(generator);

            writeSource(outputFile, cu);

            

        }