/// <summary>
        /// Transform entity type properties.
        /// </summary>
        /// <param name="entityName">Entity type properties.</param>
        /// <param name="properties">Entity type properties.</param>
        /// <returns>Transformed entity type properties.</returns>
        public List <Dictionary <string, object> > TransformProperties(string entityName, List <Dictionary <string, object> > properties)
        {
            var transformedProperties = new List <Dictionary <string, object> >();

            foreach (var property in properties)
            {
                var propTypeInfo = new EntityPropertyInfo(
                    entityName,
                    property["property-type"] as string,
                    property["property-name"] as string,
                    (property["property-isnullable"] as bool?) == true);
                var transformedProp = PropertyTransformer?.Invoke(propTypeInfo) ?? propTypeInfo;

                transformedProperties.Add(new Dictionary <string, object>
                {
                    { "property-type", transformedProp.PropertyType },
                    { "property-name", transformedProp.PropertyName },
                    { "property-annotations", property["property-annotations"] },
                    { "property-comment", property["property-comment"] },
                    { "property-isnullable", transformedProp.PropertyIsNullable },
                    { "nullable-reference-types", property["nullable-reference-types"] }
                });
            }

            return(transformedProperties);
        }
コード例 #2
0
        /// <summary>
        /// Transform single property name.
        /// </summary>
        /// <param name="propertyName">Property name.</param>
        /// <returns>Transformed property name.</returns>
        public string TransformPropertyName(string propertyName)
        {
            var propTypeInfo = new EntityPropertyInfo {
                PropertyName = propertyName
            };

            return(PropertyTransformer?.Invoke(propTypeInfo)?.PropertyName ?? propertyName);
        }
コード例 #3
0
        /// <summary>
        /// Transform entity type constructor.
        /// </summary>
        /// <param name="lines">Constructor lines.</param>
        /// <returns>Transformed constructor lines.</returns>
        public List <Dictionary <string, object> > TransformConstructor(List <Dictionary <string, object> > lines)
        {
            var transformedLines = new List <Dictionary <string, object> >();

            foreach (var line in lines)
            {
                var propTypeInfo = new EntityPropertyInfo(line["property-type"] as string,
                                                          line["property-name"] as string);
                var transformedProp = ConstructorTransformer?.Invoke(propTypeInfo) ?? propTypeInfo;

                transformedLines.Add(new Dictionary <string, object>
                {
                    { "property-name", transformedProp.PropertyName },
                    { "property-type", transformedProp.PropertyType },
                });
            }

            return(transformedLines);
        }
        /// <summary>
        /// Transform entity type navigation properties.
        /// </summary>
        /// <param name="navProperties">Entity type navigation properties.</param>
        /// <returns>Transformed entity type navigation properties.</returns>
        public List <Dictionary <string, object> > TransformNavigationProperties(List <Dictionary <string, object> > navProperties)
        {
            var transformedNavProperties = new List <Dictionary <string, object> >();

            foreach (var navProperty in navProperties)
            {
                var propTypeInfo = new EntityPropertyInfo(navProperty["nav-property-type"] as string,
                                                          navProperty["nav-property-name"] as string);
                var transformedProp = NavPropertyTransformer?.Invoke(propTypeInfo) ?? propTypeInfo;

                var newNavProperty = new Dictionary <string, object>(navProperty);
                newNavProperty["nav-property-type"] = transformedProp.PropertyType;
                newNavProperty["nav-property-name"] = transformedProp.PropertyName;

                transformedNavProperties.Add(newNavProperty);
            }

            return(transformedNavProperties);
        }
コード例 #5
0
        /// <summary>
        /// Transform entity type properties.
        /// </summary>
        /// <param name="properties">Entity type properties.</param>
        /// <returns>Transformed entity type properties.</returns>
        public List <Dictionary <string, object> > TransformProperties(List <Dictionary <string, object> > properties)
        {
            var transformedProperties = new List <Dictionary <string, object> >();

            foreach (var property in properties)
            {
                var propTypeInfo = new EntityPropertyInfo(property["property-type"] as string,
                                                          property["property-name"] as string);
                var transformedProp = PropertyTransformer?.Invoke(propTypeInfo) ?? propTypeInfo;

                transformedProperties.Add(new Dictionary <string, object>
                {
                    { "property-type", transformedProp.PropertyType },
                    { "property-name", transformedProp.PropertyName },
                    { "property-annotations", property["property-annotations"] }
                });
            }

            return(transformedProperties);
        }
コード例 #6
0
        /// <summary>
        /// Transform entity type navigation properties.
        /// </summary>
        /// <param name="navProperties">Entity type navigation properties.</param>
        /// <returns>Transformed entity type navigation properties.</returns>
        public List <Dictionary <string, object> > TransformNavigationProperties(List <Dictionary <string, object> > navProperties)
        {
            var transformedNavProperties = new List <Dictionary <string, object> >();

            foreach (var navProperty in navProperties)
            {
                var propTypeInfo = new EntityPropertyInfo(navProperty["nav-property-type"] as string,
                                                          navProperty["nav-property-name"] as string);
                var transformedProp = NavPropertyTransformer?.Invoke(propTypeInfo) ?? propTypeInfo;

                transformedNavProperties.Add(new Dictionary <string, object>
                {
                    { "nav-property-collection", navProperty["nav-property-collection"] },
                    { "nav-property-type", transformedProp.PropertyType },
                    { "nav-property-name", transformedProp.PropertyName },
                    { "nav-property-annotations", navProperty["nav-property-annotations"] }
                });
            }

            return(transformedNavProperties);
        }