Skip to content

Commit

Permalink
Katana GA Update
Browse files Browse the repository at this point in the history
  • Loading branch information
dstrockis committed Aug 20, 2014
1 parent 82c1fa5 commit 7cdd35f
Show file tree
Hide file tree
Showing 71 changed files with 15,903 additions and 11,179 deletions.
2 changes: 1 addition & 1 deletion TodoListService/Areas/HelpPage/ApiDescriptionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static string GetFriendlyId(this ApiDescription description)
localPath.Replace("/", "-").Replace("{", String.Empty).Replace("}", String.Empty));
if (queryKeyString != null)
{
friendlyPath.AppendFormat("_{0}", queryKeyString);
friendlyPath.AppendFormat("_{0}", queryKeyString.Replace('.', '-'));
}
return friendlyPath.ToString();
}
Expand Down
62 changes: 62 additions & 0 deletions TodoListService/Areas/HelpPage/App_Start/HelpPageConfig.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
// Uncomment the following to provide samples for PageResult<T>. Must also add the Microsoft.AspNet.WebApi.OData
// package to your project.
////#define Handle_PageResultOfT

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net.Http.Headers;
using System.Reflection;
using System.Web;
using System.Web.Http;
#if Handle_PageResultOfT
using System.Web.Http.OData;
#endif

namespace TodoListService.Areas.HelpPage
{
Expand All @@ -13,6 +25,12 @@ namespace TodoListService.Areas.HelpPage
/// </summary>
public static class HelpPageConfig
{
[SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters",
MessageId = "TodoListService.Areas.HelpPage.TextSample.#ctor(System.String)",
Justification = "End users may choose to merge this string with existing localized resources.")]
[SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly",
MessageId = "bsonspec",
Justification = "Part of a URI.")]
public static void Register(HttpConfiguration config)
{
//// Uncomment the following to use the documentation from XML documentation file.
Expand All @@ -27,6 +45,20 @@ public static void Register(HttpConfiguration config)
// {typeof(IEnumerable<string>), new string[]{"sample 1", "sample 2"}}
//});

// Extend the following to provide factories for types not handled automatically (those lacking parameterless
// constructors) or for which you prefer to use non-default property values. Line below provides a fallback
// since automatic handling will fail and GeneratePageResult handles only a single type.
#if Handle_PageResultOfT
config.GetHelpPageSampleGenerator().SampleObjectFactories.Add(GeneratePageResult);
#endif

// Extend the following to use a preset object directly as the sample for all actions that support a media
// type, regardless of the body parameter or return type. The lines below avoid display of binary content.
// The BsonMediaTypeFormatter (if available) is not used to serialize the TextSample object.
config.SetSampleForMediaType(
new TextSample("Binary JSON content. See http://bsonspec.org for details."),
new MediaTypeHeaderValue("application/bson"));

//// Uncomment the following to use "[0]=foo&[1]=bar" directly as the sample for all actions that support form URL encoded format
//// and have IEnumerable<string> as the body parameter or return type.
//config.SetSampleForType("[0]=foo&[1]=bar", new MediaTypeHeaderValue("application/x-www-form-urlencoded"), typeof(IEnumerable<string>));
Expand All @@ -47,5 +79,35 @@ public static void Register(HttpConfiguration config)
//// The sample will be generated as if the controller named "Values" and action named "Post" were returning a string.
//config.SetActualResponseType(typeof(string), "Values", "Post");
}

#if Handle_PageResultOfT
private static object GeneratePageResult(HelpPageSampleGenerator sampleGenerator, Type type)
{
if (type.IsGenericType)
{
Type openGenericType = type.GetGenericTypeDefinition();
if (openGenericType == typeof(PageResult<>))
{
// Get the T in PageResult<T>
Type[] typeParameters = type.GetGenericArguments();
Debug.Assert(typeParameters.Length == 1);

// Create an enumeration to pass as the first parameter to the PageResult<T> constuctor
Type itemsType = typeof(List<>).MakeGenericType(typeParameters);
object items = sampleGenerator.GetSampleObject(itemsType);

// Fill in the other information needed to invoke the PageResult<T> constuctor
Type[] parameterTypes = new Type[] { itemsType, typeof(Uri), typeof(long?), };
object[] parameters = new object[] { items, null, (long)ObjectGenerator.DefaultCollectionSize, };

// Call PageResult(IEnumerable<T> items, Uri nextPageLink, long? count) constructor
ConstructorInfo constructor = type.GetConstructor(parameterTypes);
return constructor.Invoke(parameters);
}
}

return null;
}
#endif
}
}
20 changes: 19 additions & 1 deletion TodoListService/Areas/HelpPage/Controllers/HelpController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Web.Http;
using System.Web.Mvc;
using TodoListService.Areas.HelpPage.ModelDescriptions;
using TodoListService.Areas.HelpPage.Models;

namespace TodoListService.Areas.HelpPage.Controllers
Expand All @@ -10,6 +11,8 @@ namespace TodoListService.Areas.HelpPage.Controllers
/// </summary>
public class HelpController : Controller
{
private const string ErrorViewName = "Error";

public HelpController()
: this(GlobalConfiguration.Configuration)
{
Expand Down Expand Up @@ -39,7 +42,22 @@ public ActionResult Api(string apiId)
}
}

return View("Error");
return View(ErrorViewName);
}

public ActionResult ResourceModel(string modelName)
{
if (!String.IsNullOrEmpty(modelName))
{
ModelDescriptionGenerator modelDescriptionGenerator = Configuration.GetModelDescriptionGenerator();
ModelDescription modelDescription;
if (modelDescriptionGenerator.GeneratedModels.TryGetValue(modelName, out modelDescription))
{
return View(modelDescription);
}
}

return View(ErrorViewName);
}
}
}
83 changes: 64 additions & 19 deletions TodoListService/Areas/HelpPage/HelpPage.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
pre.wrapped {
.help-page h1,
.help-page .h1,
.help-page h2,
.help-page .h2,
.help-page h3,
.help-page .h3,
#body.help-page,
.help-page-table th,
.help-page-table pre,
.help-page-table p {
font-family: "Segoe UI Light", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif;
}

.help-page pre.wrapped {
white-space: -moz-pre-wrap;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
white-space: pre-wrap;
}

.warning-message-container {
.help-page .warning-message-container {
margin-top: 20px;
padding: 0 10px;
color: #525252;
Expand All @@ -18,23 +31,24 @@ pre.wrapped {
border-collapse: collapse;
text-align: left;
margin: 0px 0px 20px 0px;
border-top: 2px solid #D4D4D4;
border-top: 1px solid #D4D4D4;
}

.help-page-table th {
text-align: left;
font-weight: bold;
border-bottom: 2px solid #D4D4D4;
padding: 8px 6px 8px 6px;
border-bottom: 1px solid #D4D4D4;
padding: 5px 6px 5px 6px;
}

.help-page-table td {
border-bottom: 2px solid #D4D4D4;
padding: 15px 8px 15px 8px;
border-bottom: 1px solid #D4D4D4;
padding: 10px 8px 10px 8px;
vertical-align: top;
}

.help-page-table pre, .help-page-table p {
.help-page-table pre,
.help-page-table p {
margin: 0px;
padding: 0px;
font-family: inherit;
Expand All @@ -45,21 +59,21 @@ pre.wrapped {
background-color: #F3F3F3;
}

a:hover {
.help-page a:hover {
background-color: transparent;
}

.sample-header {
.help-page .sample-header {
border: 2px solid #D4D4D4;
background: #76B8DB;
background: #00497E;
color: #FFFFFF;
padding: 8px 15px;
border-bottom: none;
display: inline-block;
margin: 10px 0px 0px 0px;
}

.sample-content {
.help-page .sample-content {
display: block;
border-width: 0;
padding: 15px 20px;
Expand All @@ -68,22 +82,53 @@ a:hover {
margin: 0px 0px 10px 0px;
}

.api-name {
.help-page .api-name {
width: 40%;
}

.api-documentation {
.help-page .api-documentation {
width: 60%;
}

.parameter-name {
.help-page .parameter-name {
width: 20%;
}

.parameter-documentation {
width: 50%;
.help-page .parameter-documentation {
width: 40%;
}

.help-page .parameter-type {
width: 20%;
}

.help-page .parameter-annotations {
width: 20%;
}

.help-page h1,
.help-page .h1 {
font-size: 36px;
line-height: normal;
}

.help-page h2,
.help-page .h2 {
font-size: 24px;
}

.help-page h3,
.help-page .h3 {
font-size: 20px;
}

#body.help-page {
font-size: 14px;
line-height: 143%;
color: #333;
}

.parameter-source {
width: 30%;
.help-page a {
color: #0000EE;
text-decoration: none;
}
Loading

0 comments on commit 7cdd35f

Please sign in to comment.