예제 #1
0
        private void RenderFromDocAttributes(ControllerContext context)
        {
            StringBuilder output = new StringBuilder();
            Dictionary <string, List <DocInfo> > documentation = new Dictionary <string, List <DocInfo> >();

            if (ClassNames.Length > 0)
            {
                Incubator             container = ServiceContainer;
                HttpServerUtilityBase server    = context.HttpContext.Server;
                ClassNames.Each(cn =>
                {
                    Type type     = container[cn];
                    documentation = DocInfo.FromDocAttributes(type);
                });
            }

            if (Renderer != null)
            {
                Renderer(documentation, output);
                context.HttpContext.Response.Write(output.ToString());
            }
            else
            {
                context.HttpContext.Response.Write("Attribute documentation renderer not specified.  Set DocResult.AttributeRenderer per request or set DocResult.DefaultAttributeRenderer for global effect");
            }
        }
예제 #2
0
        public string GetParameterDescription(ParameterInfo parameterInfo)
        {
            DocInfo   methodDoc = new DocInfo((MethodInfo)parameterInfo.Member);
            ParamInfo paramInfo = methodDoc.ParamInfos.FirstOrDefault(pi => pi.Name.Equals(parameterInfo.Name));

            if (paramInfo != null)
            {
                return(paramInfo.Description);
            }
            return(string.Empty);
        }
예제 #3
0
        public string GetTypeDescription(Type type)
        {
            DocInfo.AddDocInfos(_docInfosByTypeName, type);
            string  memberName = $"{type.Namespace}.{type.Name}";
            DocInfo docInfo    = _docInfosByTypeName[type.AssemblyQualifiedName].FirstOrDefault(di => di.MemberType == ClassMemberType.Method && di.MemberName.Equals(memberName));

            if (docInfo != null)
            {
                return(docInfo.Summary);
            }
            return(string.Empty);
        }
예제 #4
0
        public string GetParameterDescription(ParameterInfo parameterInfo)
        {
            MemberInfo method = parameterInfo.Member;
            Type       type   = method.DeclaringType;

            DocInfo.AddDocInfos(_docInfosByTypeName, type);
            string  memberName = $"{type.Namespace}.{type.Name}.{method.Name}";
            DocInfo docInfo    = _docInfosByTypeName[method.DeclaringType.AssemblyQualifiedName].FirstOrDefault(di => di.MemberType == ClassMemberType.Method && di.MemberName.Equals(memberName));

            if (docInfo != null)
            {
                return(docInfo.Summary);
            }
            return(string.Empty);
        }
예제 #5
0
        internal static Dictionary <string, List <DocInfo> > FromXmlFile(FileInfo file)
        {
            Args.ThrowIfNull(file, "file");

            Dictionary <string, List <DocInfo> > tempResults = new Dictionary <string, List <DocInfo> >();

            if (file.Exists)
            {
                doc    doc          = file.FromXmlFile <doc>();
                string assemblyName = doc.assembly.name;
                if (doc.members != null && doc.members.Items != null)
                {
                    doc.members.Items.Each(mem =>
                    {
                        DocInfo info      = new DocInfo();
                        info.AssemblyName = assemblyName;
                        string memberName;
                        info.MemberType = GetMemberType(mem.name, out memberName);
                        info.MemberName = memberName;
                        info.From       = DocInfoFrom.Xml;

                        #region ugly

                        if (mem.Items != null)
                        {
                            mem.Items.Each(memberItem =>
                            {
                                if (!info.TrySetSummary(memberItem))
                                {
                                    if (!info.TrySetRemarks(memberItem))
                                    {
                                        if (!info.TrySetExample(memberItem))
                                        {
                                            if (!info.TrySetValue(memberItem))
                                            {
                                                if (!info.TrySetReturns(memberItem))
                                                {
                                                    if (!info.TrySetParam(memberItem))
                                                    {
                                                        if (!info.TrySetTypeParam(memberItem))
                                                        {
                                                            if (!info.TrySetCode(memberItem))
                                                            {
                                                                if (!info.TrySetException(memberItem))
                                                                {
                                                                    if (!info.TrySetPermission(memberItem))
                                                                    {
                                                                        info.TrySetSeeAlso(memberItem);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            });
                        }
                        #endregion

                        if (!tempResults.ContainsKey(memberName))
                        {
                            tempResults.Add(memberName, new List <DocInfo>());
                        }

                        tempResults[memberName].Add(info);
                    });
                }
            }
            else
            {
                Log.AddEntry("Requested DocInfo Dictionary for non-existent file: {0}", file.FullName);
            }

            return(tempResults);
        }