Пример #1
0
        //note: this method is very careful to check that the generated URLs exist in MonoDoc
        //because if we send nonexistent URLS to MonoDoc, it shows empty pages
        public static string GetMonoDocHelpUrl(ResolveResult result)
        {
            if (result == null)
            {
                return(null);
            }

            if (result is AggregatedResolveResult)
            {
                result = ((AggregatedResolveResult)result).PrimaryResult;
            }


            if (result is NamespaceResolveResult)
            {
                string namespc = ((NamespaceResolveResult)result).Namespace;
                //verify that the namespace exists in the help tree
                //FIXME: GetHelpXml doesn't seem to work for namespaces, so forced to do full render
                Monodoc.Node dummy;
                if (!String.IsNullOrEmpty(namespc) && HelpTree != null && HelpTree.RenderUrl("N:" + namespc, out dummy) != null)
                {
                    return("N:" + namespc);
                }
                else
                {
                    return(null);
                }
            }

            IMember member = null;

            if (result is MethodResolveResult)
            {
                member = ((MethodResolveResult)result).MostLikelyMethod;
            }
            else if (result is MemberResolveResult)
            {
                member = ((MemberResolveResult)result).ResolvedMember;
            }
            try {
                if (member != null && member.GetMonodocDocumentation() != null)
                {
                    return(member.HelpUrl);
                }
            } catch (Exception) {
            }
            IReturnType type = result.ResolvedType;

            if (type != null && !String.IsNullOrEmpty(type.FullName))
            {
                string t = "T:" + type.FullName;
                if (HelpTree != null && HelpTree.GetHelpXml(t) != null)
                {
                    return(t);
                }
            }

            return(null);
        }
Пример #2
0
        //note: this method is very careful to check that the generated URLs exist in MonoDoc
        //because if we send nonexistent URLS to MonoDoc, it shows empty pages
        public static string GetMonoDocHelpUrl(ResolveResult result)
        {
            if (result == null)
            {
                return(null);
            }

            //			if (result is AggregatedResolveResult)
            //				result = ((AggregatedResolveResult)result).PrimaryResult;


            if (result is NamespaceResolveResult)
            {
                string namespc = ((NamespaceResolveResult)result).NamespaceName;
                //verify that the namespace exists in the help tree
                //FIXME: GetHelpXml doesn't seem to work for namespaces, so forced to do full render
#if MONODOC
                Monodoc.Node dummy;
#pragma warning disable 612,618
                if (!String.IsNullOrEmpty(namespc) && HelpTree != null && HelpTree.RenderUrl("N:" + namespc, out dummy) != null)
#pragma warning restore 612,618
                {
                    return("N:" + namespc);
                }
                else
#endif
                return(null);
            }

            IMember member = null;
            //			if (result is MethodGroupResolveResult)
            //				member = ((MethodGroupResolveResult)result).Methods.FirstOrDefault ();
            //			else
            if (result is MemberResolveResult)
            {
                member = ((MemberResolveResult)result).Member;
            }

            if (member != null && member.GetMonodocDocumentation() != null)
            {
                return(member.GetIdString());
            }

#if MONODOC
            var type = result.Type;
            if (type != null && !String.IsNullOrEmpty(type.FullName))
            {
                string t = "T:" + type.FullName;
#pragma warning disable 612,618
                if (HelpTree != null && HelpTree.GetHelpXml(t) != null)
#pragma warning restore 612,618
                {
                    return(t);
                }
            }
#endif
            return(null);
        }