123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
-
-
-
-
- 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 CacheControl_test.Areas.HelpPage
- {
-
-
-
-
-
- public static class HelpPageConfig
- {
- [SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters",
- MessageId = "CacheControl_test.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)
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #if Handle_PageResultOfT
- config.GetHelpPageSampleGenerator().SampleObjectFactories.Add(GeneratePageResult);
- #endif
-
-
-
-
- config.SetSampleForMediaType(
- new TextSample("Binary JSON content. See http://bsonspec.org for details."),
- new MediaTypeHeaderValue("application/bson"));
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
-
- #if Handle_PageResultOfT
- private static object GeneratePageResult(HelpPageSampleGenerator sampleGenerator, Type type)
- {
- if (type.IsGenericType)
- {
- Type openGenericType = type.GetGenericTypeDefinition();
- if (openGenericType == typeof(PageResult<>))
- {
-
- Type[] typeParameters = type.GetGenericArguments();
- Debug.Assert(typeParameters.Length == 1);
-
-
- Type itemsType = typeof(List<>).MakeGenericType(typeParameters);
- object items = sampleGenerator.GetSampleObject(itemsType);
-
-
- Type[] parameterTypes = new Type[] { itemsType, typeof(Uri), typeof(long?), };
- object[] parameters = new object[] { items, null, (long)ObjectGenerator.DefaultCollectionSize, };
-
-
- ConstructorInfo constructor = type.GetConstructor(parameterTypes);
- return constructor.Invoke(parameters);
- }
- }
-
- return null;
- }
- #endif
- }
- }
|