Пример #1
0
 private string GenerateType(Category category, Section section, DocumentationType type)
 {
     return(Templates.Type
            .Replace(DocumentationGenerator.CategoryNameTag, category.Name)
            .Replace(DocumentationGenerator.CategoryNiceNameTag, category.NiceName)
            .Replace(DocumentationGenerator.CategoryIdTag, category.Id)
            .Replace(DocumentationGenerator.SectionNameTag, section.Name)
            .Replace(DocumentationGenerator.SectionNiceNameTag, section.NiceName)
            .Replace(DocumentationGenerator.SectionIdTag, section.Id)
            .Replace(DocumentationGenerator.TypeNameTag, type.Name)
            .Replace(DocumentationGenerator.TypeNiceNameTag, type.NiceName)
            .Replace(DocumentationGenerator.TypeIdTag, type.Id)
            .Replace(DocumentationGenerator.TypeFilenameTag, type.Filename));
 }
Пример #2
0
        private string GenerateValues(DocumentationType type, DocumentationCategory category)
        {
            var binding = GetBindingFlags();
            var builder = new StringBuilder();

            if (IncludedMemberTypes.HasFlag(MemberType.EnumValue))
            {
                var values = type.Type.GetFields(binding);

                if (values.Length > 0)
                {
                    var content = GetMembers(values, GenerateField, category, category.Templates.MemberSeparator);
                    builder.Append(content);
                }
            }

            return(builder.ToString());
        }
Пример #3
0
        public string Generate(DocumentationType type, DocumentationCategory category)
        {
            var niceName = DocumentationGenerator.GetNiceName(Name);
            var id       = DocumentationGenerator.GetId(Name);

            var members = type.Type.IsEnum
                                ? GenerateValues(type, category)
                                : GenerateMembers(type, category);

            return(!string.IsNullOrEmpty(members)
                                ? category.Templates.Section
                   .Replace(DocumentationGenerator.SectionNameTag, Name)
                   .Replace(DocumentationGenerator.SectionNiceNameTag, niceName)
                   .Replace(DocumentationGenerator.SectionIdTag, id)
                   .Replace(DocumentationGenerator.TypeIdTag, type.Id)
                   .Replace(DocumentationGenerator.TypeIdTag, type.Name)
                   .Replace(DocumentationGenerator.TypeIdTag, type.NiceName)
                   .Replace(_membersTag, members)
                                : "");
        }
Пример #4
0
        private string GenerateMembers(DocumentationType type, DocumentationCategory category)
        {
            var binding = GetBindingFlags();
            var builder = new StringBuilder();
            var first   = true;

            if (IncludedMemberTypes.HasFlag(MemberType.Constructor))
            {
                var constructors = type.Type.GetConstructors(binding)
                                   .Where(constructor => IsIncluded(constructor, IncludedAccessLevels))
                                   .ToArray();

                if (constructors.Length > 0)
                {
                    var content = GetMembers(constructors, GenerateConstructor, category, category.Templates.MemberSeparator);
                    builder.Append(content);
                    first = false;
                }
            }

            if (IncludedMemberTypes.HasFlag(MemberType.Field))
            {
                var fields = type.Type.GetFields(binding)
                             .Where(field => IsIncluded(field, IncludedAccessLevels))
                             .ToArray();

                if (fields.Length > 0)
                {
                    var content = GetMembers(fields, GenerateField, category, category.Templates.MemberSeparator);

                    if (!first)
                    {
                        builder.Append(category.Templates.MemberSeparator);
                    }
                    builder.Append(content);
                    first = false;
                }
            }

            if (IncludedMemberTypes.HasFlag(MemberType.Property))
            {
                // setter access is determined later and specified via a read only decorator - set only is not supported

                var properties = type.Type.GetProperties(binding)
                                 .Where(property => IsIncluded(property.GetMethod, IncludedAccessLevels))
                                 .ToArray();

                if (properties.Length > 0)
                {
                    var content = GetMembers(properties, GenerateProperty, category, category.Templates.MemberSeparator);

                    if (!first)
                    {
                        builder.Append(category.Templates.MemberSeparator);
                    }
                    builder.Append(content);
                    first = false;
                }
            }

            if (IncludedMemberTypes.HasFlag(MemberType.Method))
            {
                var methods = type.Type.GetMethods(binding)
                              .Where(method => IsIncluded(method, IncludedAccessLevels))
                              .Where(method => !_ignoredMethods.Contains(method.Name))
                              .Where(method => !method.IsSpecialName)
                              .ToArray();

                if (methods.Length > 0)
                {
                    var content = GetMembers(methods, GenerateMethod, category, category.Templates.MemberSeparator);

                    if (!first)
                    {
                        builder.Append(category.Templates.MemberSeparator);
                    }
                    builder.Append(content);
                    first = false;
                }
            }

            return(builder.ToString());
        }