GetPropertyDictionaryForTypeGeneration() public static method

Gets the property dictionary to be used for type generation.
public static GetPropertyDictionaryForTypeGeneration ( IEnumerable types, Castle.Sharp2Js.JsGeneratorOptions generatorOptions, List propertyTypeCollection = null ) : IEnumerable
types IEnumerable The types to generate property information for.
generatorOptions Castle.Sharp2Js.JsGeneratorOptions The generator options.
propertyTypeCollection List The output collection of properties discovered through reflection of the supplied classes.
return IEnumerable
Exemplo n.º 1
0
        /// <summary>
        /// Generates a string containing js definitions of the provided types and all implied descendant types.
        /// </summary>
        /// <param name="typesToGenerate">The types to generate.</param>
        /// <param name="generatorOptions">The generator options. Uses global settings if not provided.</param>
        /// <returns></returns>
        public static string Generate(IEnumerable <Type> typesToGenerate, JsGeneratorOptions generatorOptions = null)
        {
            var passedOptions = generatorOptions ?? Options;

            if (passedOptions == null)
            {
                throw new ArgumentNullException(nameof(passedOptions), "Options cannot be null.");
            }
            var propertyClassCollection = TypePropertyDictionaryGenerator.GetPropertyDictionaryForTypeGeneration(typesToGenerate, passedOptions);
            var js = GenerateJs(propertyClassCollection, passedOptions);

            return(js);
        }
Exemplo n.º 2
0
        public static string GenerateJsModelFromTypeWithDescendants(Type modelType, bool camelCasePropertyNames, string outputNamespace)
        {
            var propertyDictionary = TypePropertyDictionaryGenerator.GetPropertyDictionaryForTypeGeneration(new[] { modelType }, Options);

            return(GenerateJs(propertyDictionary, new JsGeneratorOptions()
            {
                CamelCase = camelCasePropertyNames,
                ClassNameConstantsToRemove = new List <string>()
                {
                    "Dto"
                },
                OutputNamespace = outputNamespace,
                IncludeMergeFunction = true
            }));
        }