Example #1
0
        public static IHtmlString MethodClassificationName(this ApiServices context, DocumentedMethod type)
        {
            if (type != null)
            {
                if (type.Metadata.IsAlias)
                {
                    if (type.Metadata.IsPropertyAlias)
                    {
                        return MvcHtmlString.Create("Cake Property Alias");
                    }
                    return MvcHtmlString.Create("Cake Method Alias");
                }

                switch (type.MethodClassification)
                {
                    case MethodClassification.Constructor:
                        return MvcHtmlString.Create("Constructor");
                    case MethodClassification.EventAccessor:
                        return MvcHtmlString.Create("Event");
                    case MethodClassification.ExtensionMethod:
                        return MvcHtmlString.Create("Extension Method");
                    case MethodClassification.Method:
                        return MvcHtmlString.Create("Method");
                    case MethodClassification.Operator:
                        return MvcHtmlString.Create("Operator");
                    default:
                        return MvcHtmlString.Create("Unknown");
                }
            }
            return MvcHtmlString.Create(string.Empty);
        }
Example #2
0
 private string GetUrl(DocumentedMethod method)
 {
     var nsRoute = _service.GetRoutePart(method.Type.Namespace);
     var typeRoute = _service.GetRoutePart(method.Type);
     var methodRoute = _service.GetRoutePart(method);
     return string.Concat(nsRoute, "/", typeRoute, "/", methodRoute);
 }
Example #3
0
 public static IHtmlString BreadCrumb(this ApiServices context, DocumentedMethod method)
 {
     var breadcrumb = new Breadcrumb();
     breadcrumb.AppendApiRoot();
     breadcrumb.AppendNamespaces(context, method.Type.Namespace, true);
     breadcrumb.AppendType(context, method.Type, true);
     breadcrumb.AppendMethod(context, method);
     return breadcrumb.Render();
 }
Example #4
0
 public static IHtmlString MethodLink(this ApiServices context, DocumentedMethod method, MethodRenderOption options)
 {
     if (method != null)
     {
         var signature = context.SignatureResolver.GetMethodSignature(method);
         return context.SignatureRenderer.Render(signature, MethodRenderOption.Link | options);
     }
     return MvcHtmlString.Empty;
 }
Example #5
0
 public MethodSignature GetMethodSignature(DocumentedMethod method)
 {
     MethodSignature signature;
     if (_documentedMethods.TryGetValue(method, out signature))
     {
         return signature;
     }
     var message = string.Format("Could not find signature for {0}.", method.Identity);
     throw new InvalidOperationException(message);
 }
Example #6
0
        public static IHtmlString MethodName(this ApiServices context, DocumentedMethod method)
        {
            if (method != null)
            {
                var options = MethodRenderOption.Name | MethodRenderOption.Parameters;
                options = FixOptions(method, options);

                var signature = context.SignatureResolver.GetMethodSignature(method);
                return context.SignatureRenderer.Render(signature, MethodRenderOption.Name | MethodRenderOption.Parameters);
            }
            return MvcHtmlString.Empty;
        }
Example #7
0
 private static MethodRenderOption FixOptions(DocumentedMethod method, MethodRenderOption options)
 {
     if (method.Metadata.IsAlias)
     {
         if (method.Metadata.IsPropertyAlias)
         {
             options |= MethodRenderOption.PropertyAlias;
         }
         else
         {
             options |= MethodRenderOption.MethodAlias;
         }
     }
     return options;
 }
Example #8
0
 public static IHtmlString MethodLink(this ApiServices context, DocumentedMethod method)
 {
     return MethodLink(context, method, MethodRenderOption.Name | MethodRenderOption.Parameters);
 }
Example #9
0
 public string GetRoutePart(DocumentedMethod method)
 {
     return string.Format("{0:X8}", method.Identity.GetHashCode()).ToLowerInvariant();
 }
Example #10
0
 public MethodViewModel(DocumentedMethod data)
 {
     Data = data;
 }
Example #11
0
 public string GetRoutePart(DocumentedMethod method)
 {
     return $"{method.Identity.GetHashCode():X8}".ToLowerInvariant();
 }
Example #12
0
 public static IHtmlString Syntax(this ApiServices context, DocumentedMethod method)
 {
     return context.SyntaxRenderer.Render(method.Definition.GetMethodSignature(null));
 }
Example #13
0
 public static void AppendMethod(this IBreadcrumbItem breadcrumb, ApiServices context, DocumentedMethod method)
 {
     if (method.Definition.IsConstructor)
     {
         breadcrumb.Append(new BreadcrumbItem("Constructor"));
     }
     else
     {
         var methodSignature = context.SignatureResolver.GetMethodSignature(method);
         breadcrumb.Append(new BreadcrumbItem(context.SignatureRenderer.Render(methodSignature, MethodRenderOption.Name), null));
     }
 }