CIAPI.CodeGenerator.JsSchemaParser.BeginCodeFile C# (CSharp) Method

BeginCodeFile() public method

public BeginCodeFile ( Stream output ) : void
output Stream
return void
        public override void BeginCodeFile(Stream output)
        {
            throw new NotImplementedException();
        }

Usage Example

        private static void Main(string[] args)
        {
            var opt = new Options();
            var cmdParser = new CommandLineParser(new CommandLineParserSettings(Console.Error));
            if (!cmdParser.ParseArguments(args, opt))
            {
                // #TODO: usage; if this tool is to be developed further
                Environment.Exit(1);
            }


            string schemaJson = File.ReadAllText(opt.InputFile);
            bool flattenHierarchy = opt.FlattenHierarchy;
            string nspace = opt.NSpace;


            var lang = opt.Language;

            SchemaParser schemaParser;

            switch (lang)
            {
                case Lang.CS:
                    var imports = opt.Imports == null ? new string[] { } : opt.Imports.Split(',');
                    schemaParser = new CSharpSchemaParser(schemaJson, imports, nspace);
                    break;
                case Lang.JS:
                    schemaParser = new JsSchemaParser(schemaJson);
                    break;
                default:
                    throw new Exception("unrecognized language option");
            }


            var output = new FileStream(opt.OutputFile, FileMode.Create, FileAccess.Write);
            
            schemaParser.BeginCodeFile(output);
            schemaParser.EmitTypes(output, flattenHierarchy);
            schemaParser.EndCodeFile(output);

            output.Close();
        }