Example #1
0
        public HelpControllerVersionAttribute GetControllerVersion(HelpTopicAttribute topic)
        {
            if (topic.TopicType != HelpTopicType.Controller)
            {
                return(null);
            }
            var version = topic.Parts.FirstOrDefault(x => x.PartType == HelpPartType.ControllerVersion);

            return(version as HelpControllerVersionAttribute);
        }
Example #2
0
 public List <HelpTopicAttribute> GetUsedBy(HelpTopicAttribute topic)
 {
     //=========for these cases some 'Used by' are excluded as already dealt with using other ways.
     if (topic.TopicType == HelpTopicType.Response)
     {
         return(topic.UsedBy.Where(x => x.TopicType != HelpTopicType.Action).ToList());
     }
     if (topic.TopicType == HelpTopicType.Action)
     {
         return(topic.UsedBy.Where(x => x.TopicType != HelpTopicType.Controller).ToList());
     }
     //\=========
     return(topic.UsedBy);
 }
        private static void BuildActionTopic(HelpTopicAttribute helpTopicAtt, MethodInfo methodInfo, List <HelpTopicAttribute> ret)
        {
            SetParts(helpTopicAtt, methodInfo.GetCustomAttributes(typeof(HelpPartAttribute)));

            //get action request and response topic
            var types = helpTopicAtt.Parts.Where(x => x is HelpRequestResponseAttribute).Cast <HelpRequestResponseAttribute>().ToList();

            foreach (var t in types)
            {
                var att = t.Type.GetCustomAttribute(typeof(HelpTopicAttribute));
                if (att is HelpTopicAttribute tHelpAtt)
                {
                    var found = ret.FirstOrDefault(x => x.ID == t.Type.FullName);
                    if (found != null)
                    {
                        //avoid adding duplicate
                        tHelpAtt = found;
                    }

                    LinkTopics(helpTopicAtt, tHelpAtt);
                    BuildTypeTopic(tHelpAtt, t.Type, ret);
                }
            }
        }
        private static void BuildControllerParts(HelpTopicAttribute helpTopicAtt, Type conrollerType, List <HelpTopicAttribute> ret)
        {
            SetParts(helpTopicAtt, conrollerType.GetCustomAttributes(typeof(HelpPartAttribute)));

            //get controller actions
            var tMethods = conrollerType.GetMethods(BindingFlags.Instance | BindingFlags.Public);

            foreach (var tm in tMethods)
            {
                if (tm.MemberType == MemberTypes.Method)
                {
                    var att = tm.GetCustomAttribute(typeof(HelpTopicAttribute));
                    if (att is HelpTopicAttribute mhelpAtt)
                    {
                        mhelpAtt.ID = mhelpAtt.ID + "." + tm.Name;

                        ret.Add(mhelpAtt);

                        LinkTopics(helpTopicAtt, mhelpAtt);
                        BuildActionTopic(mhelpAtt, tm, ret);
                    }
                }
            }
        }
Example #5
0
        public List <HelpTopicAttribute> GetUses(HelpTopicAttribute topic)
        {
            //=========for these cases some 'Uses' are excluded as already dealt with using other ways.
            if (topic.TopicType == HelpTopicType.Controller)
            {
                return(topic.Uses.Where(x => x.TopicType != HelpTopicType.Action).ToList());
            }

            if (topic.TopicType == HelpTopicType.Action)
            {
                return(topic.Uses.Where(x => x.TopicType != HelpTopicType.Response &&
                                        x.TopicType != HelpTopicType.Request).ToList());
            }

            if (topic.TopicType == HelpTopicType.Response ||
                topic.TopicType == HelpTopicType.Request ||
                topic.TopicType == HelpTopicType.DataType)
            {
                return(topic.Uses.Where(x => x.TopicType != HelpTopicType.DataType).ToList());
            }
            //\=========

            return(topic.Uses);
        }
 private static void LinkTopics(HelpTopicAttribute helpTopicAtt, HelpTopicAttribute mhelpAtt)
 {
     helpTopicAtt.Uses.Add(mhelpAtt);
     mhelpAtt.UsedBy.Add(helpTopicAtt);
 }
Example #7
0
        /// <summary>
        /// Get a help topic summary.
        /// </summary>
        /// <param name="topic"></param>
        /// <returns></returns>
        public string GetSummary(HelpTopicAttribute topic)
        {
            var summary = topic.Parts.FirstOrDefault(x => x.PartType == HelpPartType.Summary);

            return(InsertResources((summary as HelpSummaryAttribute)?.Summary));
        }
Example #8
0
 public List <HelpExternalLinkAttribute> GetExternalLinks(HelpTopicAttribute topic)
 {
     return(topic.Parts.Where(x => x.PartType == HelpPartType.ExternalLink).Cast <HelpExternalLinkAttribute>().ToList());
 }
Example #9
0
 public List <HelpPropertyAttribute> GetProperties(HelpTopicAttribute topic)
 {
     return(topic.Parts.Where(x => x.PartType == HelpPartType.Property).Cast <HelpPropertyAttribute>().ToList());
 }