Helper functions for Js Generator
        /// <summary>
        /// Gets the property dictionary to be used for type generation.
        /// </summary>
        /// <param name="types">The types to generate property information for.</param>
        /// <param name="generatorOptions">The generator options.</param>
        /// <param name="propertyTypeCollection">The output collection of properties discovered through reflection of the supplied classes.</param>
        /// <returns></returns>
        public static IEnumerable <PropertyBag> GetPropertyDictionaryForTypeGeneration(IEnumerable <Type> types,
                                                                                       JsGeneratorOptions generatorOptions,
                                                                                       List <PropertyBag> propertyTypeCollection = null)
        {
            if (propertyTypeCollection == null)
            {
                propertyTypeCollection = new List <PropertyBag>();
            }


            foreach (var type in types)
            {
                if (type.IsEnum)
                {
                    var getVals  = type.GetEnumNames();
                    var typeName = type.Name;
                    foreach (var enumVal in getVals)
                    {
                        if (generatorOptions.TreatEnumsAsStrings)
                        {
                            propertyTypeCollection.Add(new PropertyBag(typeName, type, enumVal, typeof(string),
                                                                       null, PropertyBag.TransformablePropertyTypeEnum.Primitive, true, enumVal));
                        }
                        else
                        {
                            var trueVal = Convert.ChangeType(Enum.Parse(type, enumVal), type.GetEnumUnderlyingType());
                            propertyTypeCollection.Add(new PropertyBag(typeName, type, enumVal, type.GetEnumUnderlyingType(),
                                                                       null, PropertyBag.TransformablePropertyTypeEnum.Primitive, true, trueVal));
                        }
                    }
                }
                else
                {
                    var props    = type.GetProperties();
                    var typeName = type.Name;
                    foreach (var prop in props)
                    {
                        if (!Helpers.ShouldGenerateMember(prop, generatorOptions))
                        {
                            continue;
                        }

                        var propertyName = Helpers.GetPropertyName(prop, generatorOptions);
                        var propertyType = prop.PropertyType;

                        if (!Helpers.IsPrimitive(propertyType))
                        {
                            if (Helpers.IsCollectionType(propertyType))
                            {
                                var collectionInnerTypes = GetCollectionInnerTypes(propertyType);
                                var isDictionaryType     = Helpers.IsDictionaryType(propertyType);

                                propertyTypeCollection.Add(new PropertyBag(typeName, type, propertyName, propertyType,
                                                                           collectionInnerTypes, isDictionaryType
                                        ? PropertyBag.TransformablePropertyTypeEnum.DictionaryType
                                        : PropertyBag.TransformablePropertyTypeEnum.CollectionType, false, null));

                                //if primitive, no need to reflect type
                                if (collectionInnerTypes.All(p => p.IsPrimitiveType))
                                {
                                    continue;
                                }

                                foreach (var collectionInnerType in collectionInnerTypes.Where(p => !p.IsPrimitiveType))
                                {
                                    var innerTypeName = collectionInnerType.Type.Name;
                                    if (propertyTypeCollection.All(p => p.TypeName != innerTypeName))
                                    {
                                        GetPropertyDictionaryForTypeGeneration(new[] { collectionInnerType.Type },
                                                                               generatorOptions, propertyTypeCollection);
                                    }
                                }
                            }
                            else
                            {
                                propertyTypeCollection.Add(new PropertyBag(typeName, type, propertyName, propertyType,
                                                                           null, PropertyBag.TransformablePropertyTypeEnum.ReferenceType, false, null));

                                if (propertyTypeCollection.All(p => p.TypeName != propertyType.Name))
                                {
                                    GetPropertyDictionaryForTypeGeneration(new[] { propertyType },
                                                                           generatorOptions, propertyTypeCollection);
                                }
                            }
                        }
                        else
                        {
                            var hasDefaultValue = Helpers.HasDefaultValue(prop, generatorOptions);
                            if (hasDefaultValue)
                            {
                                var val = Helpers.ReadDefaultValueFromAttribute(prop);
                                propertyTypeCollection.Add(new PropertyBag(typeName, type, propertyName, propertyType,
                                                                           null, PropertyBag.TransformablePropertyTypeEnum.Primitive, true, val));
                            }
                            else
                            {
                                propertyTypeCollection.Add(new PropertyBag(typeName, type, propertyName, propertyType,
                                                                           null, PropertyBag.TransformablePropertyTypeEnum.Primitive, false, null));
                            }

                            if (propertyType.IsEnum)
                            {
                                if (propertyTypeCollection.All(p => p.TypeName != propertyType.Name))
                                {
                                    GetPropertyDictionaryForTypeGeneration(new[] { propertyType },
                                                                           generatorOptions, propertyTypeCollection);
                                }
                            }
                        }
                    }
                }
            }
            return(propertyTypeCollection);
        }