private static IProviderModel convert(Template template, Type type)
        {
            // modelName is the controller name
            // example: AgencyManagementSystemController
            //  - route name default = AgencyManagementSystem
            // properties are Name = Route
            var controllerName = NameFactory.Create(type.Name.TrimEnd("Controller".ToCharArray()));
            var routes         = new List <RouteProperty>();

            foreach (var methodInfo in type.GetMethods())
            {
                var route           = getRouteInfo(methodInfo, controllerName);
                var returnType      = ReflectionUtility.GetReturnTypeInfoFromCustomAttributesWhenNeeded(methodInfo);
                var inputParameters = ReflectionUtility.GetInputParameters(methodInfo);
                routes.Add(new RouteProperty
                {
                    Name            = NameFactory.Create(route),
                    ReturnType      = returnType,
                    InputParameters = inputParameters
                });
            }
            return(new RouteModel
            {
                Imports = template.Imports,
                Properties = routes,
                Name = controllerName,
                Namespace = template.Namespace
            });
        }
예제 #2
0
        private Property getProperty(List <string> requiredProperties, string key, JToken value)
        {
            var isNullable          = getNullableStatus(requiredProperties, key, value);
            var type                = getDataType(value, isNullable);
            var propertyDescription = value["description"] != null ? value["description"].ToString() : string.Empty;
            var prop                = new Property
            {
                Name        = NameFactory.Create(key),
                Type        = type,
                Description = propertyDescription,
                IsNullable  = isNullable
            };

            return(prop);
        }
예제 #3
0
        private static IProviderModel convert(Template template, Type type)
        {
            var modelName  = NameFactory.Create(type.Name);
            var properties = new List <ReflectionProperty>();

            foreach (var propertyInfo in type.GetProperties())
            {
                var property = ReflectionPropertyFactory.Convert(modelName, propertyInfo, template.Language);
                properties.Add(property);
            }
            return(new ReflectionModel
            {
                Imports = template.Imports,
                Properties = properties,
                Name = modelName,
                Namespace = template.Namespace
            });
        }
        private static IEnumerable <SQLProperty> getProperties(Enum.Language language, ColumnCollection columns)
        {
            var properties = new List <SQLProperty>();

            foreach (Column column in columns)
            {
                var property = new SQLProperty
                {
                    DefaultValue   = column.DefaultConstraint?.Text,
                    Length         = column.DataType.MaximumLength,
                    Name           = NameFactory.Create(column.Name),
                    Nullable       = column.Nullable,
                    PrimaryKey     = column.InPrimaryKey,
                    SqlDataType    = column.DataType.SqlDataType,
                    Type           = getDataType(language, column.DataType.SqlDataType),
                    IsInPrimaryKey = column.InPrimaryKey
                };
                properties.Add(property);
            }
            return(properties);
        }
예제 #5
0
        private Model parseItem(string _namespace, string className, JToken definition)
        {
            var item = new Model
            {
                Namespace = _namespace,
                Schema    = "",
                Name      = NameFactory.Create(className)
            };

            try
            {
                item.Description = definition["description"] != null ? definition["description"].ToString() : string.Empty;
                var requiredProperties = new List <string>();
                if (definition["required"] != null)
                {
                    requiredProperties = definition["required"].Value <JArray>().Select(a => a.ToString()).ToList();
                }
                if (definition["properties"] == null)
                {
                    //some definitions don't have properties, we're just going to skip those
                    return(null);
                }
                var properties = definition["properties"].Value <JObject>();
                foreach (var(key, value) in properties)
                {
                    var prop = getProperty(requiredProperties, key, value);
                    item.Properties.Add(prop);
                }

                return(item);
            }
            catch (Exception ex)
            {
                var msg = ex.ToString();
                return(null);
            }
        }