Ejemplo n.º 1
0
 public static bool HandleHtmlTags(ITag tag, TagDocumentation documentation)
 {
     if (tag is HtmlHelperWrapperTag)
     {
         var htmlTag = (HtmlHelperWrapperTag)tag;
         var htmlHelper = new HtmlReflectionHelper(htmlTag.WrappedType, htmlTag.MethodName);
         foreach (var method in htmlHelper.AllMethods)
         {
             documentation.Methods.Add(new FunctionDocumentation("",documentation.MessagePath, new WrappedFunctionDocumentation(method)));
         }
         return true;
     }
     return false;
 }
        public TagGroupDocumentation(ResourceKeyStack messagePath, ITagGroup tagGroup, IList <Func <ITag, TagDocumentation, bool> > specials, Dictionary <int, TagDocumentation> tagDictionary)
        {
            _messagePath   = messagePath.BranchFor(tagGroup);
            _name          = tagGroup.Name;
            _specials      = specials;
            _tagDictionary = tagDictionary;
            _tags          = new List <int>();
            var tagGroupType = tagGroup.GetType();

            _description = DescriptionAttribute.Harvest(tagGroupType) ?? _messagePath.Description;

            _title = TitleAttribute.HarvestTagLibrary(tagGroupType);
            foreach (ITag _tag in tagGroup)
            {
                var hash = _tag.GetType().GetHashCode();
                if (!_tagDictionary.ContainsKey(hash))
                {
                    _tagDictionary[hash] = null;
                    var tagDoc = new TagDocumentation(_messagePath, _tag, _specials, _tagDictionary);
                    _tagDictionary[hash] = tagDoc;
                }
                _tags.Add(hash);
            }
            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));
            }
        }
Ejemplo n.º 3
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));
                }
            }
        }