Exemplo n.º 1
0
        public static String Get(JsonSchema4 schema, String ns)
        {
            String Model, model;

            NameGenerator.CreatePascalAndCamel(schema.Title, out Model, out model);
            return(Create(ns, Model));
        }
        private static String Get(JsonSchema4 schema, String modelNamespace, String modelType, String additionalNs)
        {
            String Model, model;

            NameGenerator.CreatePascalAndCamel(schema.Title, out Model, out model);
            return(Create(Model, model, modelNamespace, modelType, additionalNs));
        }
        public static String GetUserPartial(JsonSchema4 schema, String modelNamespace)
        {
            String Model, model;

            NameGenerator.CreatePascalAndCamel(schema.Title, out Model, out model);
            return(Create(Model, model, modelNamespace, NameGenerator.CreatePascal(schema.GetKeyName()), schema.GetExtraNamespaces(StrConstants.FileNewline)));
        }
Exemplo n.º 4
0
        public static String GetUserPartial(JsonSchema4 schema, String ns, String generatedSuffix = ".Generated")
        {
            String Model, model;

            NameGenerator.CreatePascalAndCamel(schema.Title, out Model, out model);
            String Models, models;

            NameGenerator.CreatePascalAndCamel(schema.GetPluralName(), out Models, out models);
            return(CreatePartial(ns, Model, model, Models, models, generatedSuffix, schema.GetExtraNamespaces(StrConstants.FileNewline)));
        }
Exemplo n.º 5
0
        public static String Get(JsonSchema4 schema)
        {
            String Model, model;

            NameGenerator.CreatePascalAndCamel(schema.Title, out Model, out model);
            String Models, models;

            NameGenerator.CreatePascalAndCamel(schema.GetPluralName(), out Models, out models);
            return(Create(Model, model, Models, models, NameGenerator.CreateCamel(schema.GetKeyName())));
        }
        public static String GetComplete(JsonSchema4 schema, String ns)
        {
            String Model, model;

            NameGenerator.CreatePascalAndCamel(schema.Title, out Model, out model);
            String Models, models;

            NameGenerator.CreatePascalAndCamel(schema.GetPluralName(), out Models, out models);

            return(Create(ns, Model, model, Models, models, schema.GetKeyType().GetTypeAsNullable(), schema.GetExtraNamespaces(StrConstants.FileNewline), true, true, true, null));
        }
        public static String Get(JsonSchema4 schema, String ns)
        {
            String Model, model;

            NameGenerator.CreatePascalAndCamel(schema.Title, out Model, out model);
            String Models, models;

            NameGenerator.CreatePascalAndCamel(schema.GetPluralName(), out Models, out models);
            String ModelId, modelId;

            NameGenerator.CreatePascalAndCamel(schema.GetKeyName(), out ModelId, out modelId);
            return(Create(ns, Model, model, Models, models, schema.GetKeyType().Name, ModelId, modelId));
        }
        public static String Get(JsonSchema4 schema, String ns, bool generated)
        {
            bool hasBase = false;

            var baseWriter = new QueryBaseModelWriter("Query", QueryPropertiesWriter.CreateAttributeBuilder())
            {
                InheritFrom = new String[] { "PagedCollectionQuery" }
            };
            var baseClass = ModelTypeGenerator.Create(schema, schema.GetPluralName(), baseWriter, ns, ns + ".Database", allowPropertyCallback: p =>
            {
                if (p.IsQueryable())
                {
                    hasBase = hasBase | p.IsAbstractOnQuery();
                    return(p.IsAbstractOnQuery());
                }
                return(false);
            });

            var baseClassName = "PagedCollectionQuery";

            if (hasBase)
            {
                baseClassName = $"{BaseModelWriter.CreateBaseClassName(schema.Title, "Query")}";
                baseClass     = $@"
{baseClass}
";
            }
            else
            {
                baseClass = "";
            }

            String Model, model;

            NameGenerator.CreatePascalAndCamel(schema.Title, out Model, out model);
            String Models, models;

            NameGenerator.CreatePascalAndCamel(schema.GetPluralName(), out Models, out models);
            String queryProps = ModelTypeGenerator.Create(schema, schema.GetPluralName(), new QueryPropertiesWriter(), schema, ns, ns, allowPropertyCallback: p =>
            {
                return(p.IsQueryable() && !p.IsAbstractOnQuery());
            });
            String queryCreate = ModelTypeGenerator.Create(schema, schema.GetPluralName(), new QueryCreateWriter(), schema, ns, ns, allowPropertyCallback: p =>
            {
                return(p.IsQueryable());
            });

            return(Create(ns, Model, model, Models, models, queryProps, queryCreate, schema.GetKeyType().GetTypeAsNullable(), baseClass, baseClassName, NameGenerator.CreatePascal(schema.GetKeyName()), schema.GetExtraNamespaces(StrConstants.FileNewline), generated));
        }
        /// <summary>
        /// Create a cshtml view. OutDir must match the folder where the view will be located, use / between folders.
        /// This is important because it will be set as the runner and must match the typescript file.
        /// </summary>
        /// <param name="schema">The schema.</param>
        /// <param name="propertyNames">The property names.</param>
        /// <returns></returns>
        public static String Get(JsonSchema4 schema, IEnumerable <String> propertyNames = null)
        {
            String Model, model;

            NameGenerator.CreatePascalAndCamel(schema.Title, out Model, out model);
            String Models, models;

            NameGenerator.CreatePascalAndCamel(schema.GetPluralName(), out Models, out models);

            if (propertyNames == null)
            {
                propertyNames = new String[] { "Thing" };
            }

            return(Create(Model, model, Models, models, propertyNames, schema.Properties.Values.Any(i => i.IsQueryableShowOnUi())));
        }
Exemplo n.º 10
0
        public static String Get(JsonSchema4 schema, String ns)
        {
            String Model, model;

            NameGenerator.CreatePascalAndCamel(schema.Title, out Model, out model);
            String Models, models;

            NameGenerator.CreatePascalAndCamel(schema.GetPluralName(), out Models, out models);

            var    authAttribute = "";
            String authName      = schema.GetAuthorizationRoleString();

            if (authName != null)
            {
                authAttribute = $@"[Authorize(Roles = {authName})]
        ";
            }
            return(Create(ns, NameGenerator.CreatePascal(schema.GetUiControllerName()), Model, model, Models, models, authAttribute));
        }
        public static String Get(JsonSchema4 schema, String ns)
        {
            String Model, model;

            NameGenerator.CreatePascalAndCamel(schema.Title, out Model, out model);
            String Models, models;

            NameGenerator.CreatePascalAndCamel(schema.GetPluralName(), out Models, out models);
            String ModelId, modelId;

            NameGenerator.CreatePascalAndCamel(schema.GetKeyName(), out ModelId, out modelId);

            var    additionalAuthorize = "";
            String authName            = schema.GetAuthorizationRoleString();

            if (authName != null)
            {
                additionalAuthorize = $", Roles = {authName}";
            }
            return(Create(ns, Model, model, Models, models, additionalAuthorize, schema.GetKeyType().Name, ModelId, modelId, schema.GetExtraNamespaces(StrConstants.FileNewline)));
        }
Exemplo n.º 12
0
        public static String Get(JsonSchema4 schema, String ns)
        {
            String Model, model;

            NameGenerator.CreatePascalAndCamel(schema.Title, out Model, out model);
            String Models, models;

            NameGenerator.CreatePascalAndCamel(schema.GetPluralName(), out Models, out models);
            String ModelId, modelId;

            NameGenerator.CreatePascalAndCamel(schema.GetKeyName(), out ModelId, out modelId);

            String queryProps = ModelTypeGenerator.Create(schema, schema.GetPluralName(), new QueryPropWriter(), schema, ns, ns, allowPropertyCallback: p =>
            {
                return(p.IsQueryable());
            });
            String customizer = ModelTypeGenerator.Create(schema, schema.GetPluralName(), new QueryCustomizerWriter(), schema, ns, ns, allowPropertyCallback: p =>
            {
                return(p.IsQueryable());
            });

            return(Create(ns, Model, model, Models, models, queryProps, customizer, schema.GetKeyType().GetTypeAsNullable(), ModelId, modelId, schema.GetExtraNamespaces(StrConstants.FileNewline)));
        }