Exemplo n.º 1
0
        public TagGroupDocumentation(ResourceKeyStack messagePath, ITagGroup tagGroup, IList<Func<ITag, TagDocumentation, bool>> specials)
        {
            _messagePath = messagePath.BranchFor(tagGroup);
            _name = tagGroup.Name;
            _specials = specials;
            _tags = new List<TagDocumentation>();
            var tagGroupType=tagGroup.GetType();
            _description=DescriptionAttribute.Harvest(tagGroupType)?? _messagePath.Description;

            _title = TitleAttribute.HarvestTagLibrary(tagGroupType);
            foreach (ITag _tag in tagGroup)
            {
                _tags.Add(new TagDocumentation(_messagePath, _tag, _specials));
            }
            if (ExampleAttribute.Harvest(tagGroupType))
            {
                _examples.AddRange(ExampleAttribute.HarvestTags(tagGroupType));
            }
            if (HasExample.Has(tagGroupType))
            {
                _examples.Add(new ExampleAttribute(_messagePath.Example));
            }
            if (NoteAttribute.Harvest(tagGroupType))
            {
                _notes.AddRange(NoteAttribute.HarvestTags(tagGroupType));
            }
            if (HasNote.Has(tagGroupType))
            {
                _notes.Add(new NoteAttribute(_messagePath.Note));
            }
        }
Exemplo n.º 2
0
 public PropertyDocumentation(ResourceKeyStack messagePath, PropertyAttribute property)
 {
     _propertyName = property.Name;
     _messagePath = messagePath.BranchFor(new AttributeInfo(property.Name, property.DeclaringType));
     _required = property.Required;
     _default = property.DefaultValue;
     _description = property.Description != null ? new DescriptionAttribute(property.Description) : _messagePath.Description;
     _enumValues = property.DeclaringType.IsEnum ? GetEnumValues(property.DeclaringType) : null;
 }
Exemplo n.º 3
0
 public PropertyDocumentation(ResourceKeyStack messagePath, PropertyInfo property)
 {
     _property = property;
     _messagePath = messagePath.BranchFor(property);
     IsRequired(property);
     DetermineDefault(property);
     _description = DescriptionAttribute.Harvest(property)??_messagePath.Description;
     _enumValues = GetEnumValues(_property.GetCustomAttribute<EnumProperyTypeAttribute>(false)?.EnumType);
 }
Exemplo n.º 4
0
        public TagDocumentation(ResourceKeyStack messagePath, ITag tag,  IList<Func<ITag, TagDocumentation,bool>> specials)
        {
            _messagePath = messagePath.BranchFor(tag);
            _name = tag.TagName;

            var tagType = tag.GetType();

            _category = CategoryHelper.GetCategory(tagType);

            _list = new List<PropertyDocumentation>();
            _nested = new List<TagDocumentation>();
            _methods = new List<FunctionDocumentation>();
            foreach (var property in tagType.GetCustomAttributes<PropertyAttribute>())
            {
                _list.Add(new PropertyDocumentation(_messagePath, property));
            }

            foreach (var property in tagType.GetProperties(
                BindingFlags.Instance |
                BindingFlags.Public |
                BindingFlags.SetProperty |
                BindingFlags.FlattenHierarchy))
            {
                if (Equals(property.PropertyType, typeof(ITagAttribute)) &&
                    !IsInternal(property))
                {
                    _list.Add(new PropertyDocumentation(_messagePath, property));
                }
            }
            var extendingTag = tag as ITagExtendTagLib;
            if (extendingTag != null)
            {
                foreach (var nested in extendingTag.TagLibExtension)
                {
                    _nested.Add(new TagDocumentation(_messagePath, nested, specials));
                }
            }
            var instanceDocumentation = tag as IInstanceTagDocumentation;
            if (instanceDocumentation!=null)
            {
                _description = instanceDocumentation.Description;
                _examples.AddRange(instanceDocumentation.Examples?? new ExampleAttribute[] {});
                _notes.AddRange(instanceDocumentation.Notes ?? new NoteAttribute[] {});
            }
            else
            {
                _description = DescriptionAttribute.Harvest(tagType) ?? _messagePath.Description;

                if (ExampleAttribute.Harvest(tagType))
                {
                    _examples.AddRange(ExampleAttribute.HarvestTags(tagType));
                }
                if (HasExample.Has(tagType))
                {
                    _examples.Add(new ExampleAttribute(_messagePath.Example));
                }
                if (NoteAttribute.Harvest(tagType))
                {
                    _notes.AddRange(NoteAttribute.HarvestTags(tagType));
                }
                if (HasNote.Has(tagType))
                {
                    _notes.Add(new NoteAttribute(_messagePath.Note));
                }
            }
        }
Exemplo n.º 5
0
        public TagDocumentation(ResourceKeyStack messagePath, ITag tag, IList <Func <ITag, TagDocumentation, bool> > specials, Dictionary <int, TagDocumentation> tagDictionary)
        {
            _tagDictionary = tagDictionary;
            _messagePath   = messagePath.BranchFor(tag);
            _name          = tag.TagName;

            var tagType = tag.GetType();

            _category = CategoryHelper.GetCategory(tagType);

            _list       = new List <PropertyDocumentation>();
            _nested     = new List <int>();
            _methods    = new List <FunctionDocumentation>();
            TagBodyMode = tag.TagBodyMode;

            foreach (var property in tagType.GetCustomAttributes <PropertyAttribute>())
            {
                _list.Add(new PropertyDocumentation(_messagePath, property));
            }

            foreach (var property in tagType.GetProperties(
                         BindingFlags.Instance |
                         BindingFlags.Public |
                         BindingFlags.SetProperty |
                         BindingFlags.FlattenHierarchy))
            {
                if (Equals(property.PropertyType, typeof(ITagAttribute)) &&
                    !IsInternal(property))
                {
                    _list.Add(new PropertyDocumentation(_messagePath, property));
                }
            }
            var extendingTag = tag as ITagExtendTagLib;

            if (extendingTag != null)
            {
                foreach (var nested in extendingTag.TagLibExtension)
                {
                    var hash = nested.GetType().GetHashCode();
                    if (!_tagDictionary.ContainsKey(hash))
                    {
                        _tagDictionary[hash] = null;
                        var tagDoc = new TagDocumentation(_messagePath, nested, specials, _tagDictionary);
                        _tagDictionary[hash] = tagDoc;
                    }
                    _nested.Add(hash);
                }
            }
            var instanceDocumentation = tag as IInstanceTagDocumentation;

            if (instanceDocumentation != null)
            {
                _description = instanceDocumentation.Description;
                _examples.AddRange(instanceDocumentation.Examples ?? new ExampleAttribute[] {});
                _notes.AddRange(instanceDocumentation.Notes ?? new NoteAttribute[] {});
            }
            else
            {
                _description = DescriptionAttribute.Harvest(tagType) ?? _messagePath.Description;

                if (ExampleAttribute.Harvest(tagType))
                {
                    _examples.AddRange(ExampleAttribute.HarvestTags(tagType));
                }
                if (HasExample.Has(tagType))
                {
                    _examples.Add(new ExampleAttribute(_messagePath.Example));
                }
                if (NoteAttribute.Harvest(tagType))
                {
                    _notes.AddRange(NoteAttribute.HarvestTags(tagType));
                }
                if (HasNote.Has(tagType))
                {
                    _notes.Add(new NoteAttribute(_messagePath.Note));
                }
            }
        }
Exemplo n.º 6
0
 public EnumValue(object value, DescriptionAttribute description)
 {
     Value = value;
     Description = description;
 }