Esempio n. 1
0
        public string GenerateModels()
        {
            var sb        = new IndentAwareStringBuilder();
            var generator = new ModelGenerator();

            foreach (var manifest in Schemas)
            {
                var ns = new Namespace(manifest.Key);

                foreach (var revisionSet in manifest.Value)
                {
                    var revision = revisionSet.Key;

                    foreach (var schema in revisionSet.Value)
                    {
                        generator.Generate(sb, ns, revision, schema);
                    }
                }
            }

            sb.InsertAutoGeneratedHeader();
            var code = sb.ToString();

            return(code);
        }
        public void Can_generate_models_from_schema()
        {
            var schema = new Schema {
                Name = "Customer"
            };

            schema.Properties.Add(new SchemaProperty {
                Name = "Name", Type = "string"
            });

            var ns = new Namespace(Constants.DefaultNamespace);
            var sb = new IndentAwareStringBuilder();

            var models = new ModelGenerator();

            models.Generate(sb, ns, 1, schema);
            sb.InsertAutoGeneratedHeader();

            _output.WriteLine(sb.ToString());
        }