Exemplo n.º 1
0
        public static string GenerateClassCode(ClassData classData)
        {
            ClassTemplate t = new ClassTemplate();

            t.Session = new Microsoft.VisualStudio.TextTemplating.TextTemplatingSession();
            t.Session["classParameters"] = classData;
            t.Session["methods"]         = classData.Methods;
            // Add other parameter values to t.Session here.
            t.Initialize(); // Must call this to transfer values.
            string resultText = t.TransformText();

            return(resultText);
        }
Exemplo n.º 2
0
        private TypeGeneratorResult GenerateClass(string typeName)
        {
            var properties = _schema.Properties.Values
                             .Select(property => new PropertyModel(property, _resolver, Settings))
                             .ToList();

            var template = new ClassTemplate() as ITemplate;

            template.Initialize(new ClassTemplateModel(typeName, Settings, _resolver, _schema, properties));
            return(new TypeGeneratorResult
            {
                TypeName = typeName,
                Code = template.Render()
            });
        }
Exemplo n.º 3
0
        private TypeGeneratorResult GenerateClass(string typeName)
        {
            var properties = _schema.AllProperties.Values
                             .Where(p => !p.IsInheritanceDiscriminator)
                             .Select(property => new PropertyModel(property, _resolver, Settings))
                             .ToList();

            RenamePropertyWithSameNameAsClass(typeName, properties);

            var model    = new ClassTemplateModel(typeName, Settings, _resolver, _schema, properties);
            var template = new ClassTemplate() as ITemplate;

            template.Initialize(model);
            return(new TypeGeneratorResult
            {
                TypeName = typeName,
                BaseTypeName = model.BaseClass,
                Code = template.Render()
            });
        }