初始化
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
@using PTS_API_V1.Areas.HelpPage
|
||||
@model InvalidSample
|
||||
|
||||
@if (HttpContext.Current.IsDebuggingEnabled)
|
||||
{
|
||||
<div class="warning-message-container">
|
||||
<p>@Model.ErrorMessage</p>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>Sample not available.</p>
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace PTS_API_V1.Areas.HelpPage.ModelDescriptions
|
||||
{
|
||||
internal static class ModelNameHelper
|
||||
{
|
||||
// Modify this to provide custom model name mapping.
|
||||
public static string GetModelName(Type type)
|
||||
{
|
||||
ModelNameAttribute modelNameAttribute = type.GetCustomAttribute<ModelNameAttribute>();
|
||||
if (modelNameAttribute != null && !String.IsNullOrEmpty(modelNameAttribute.Name))
|
||||
{
|
||||
return modelNameAttribute.Name;
|
||||
}
|
||||
|
||||
string modelName = type.Name;
|
||||
if (type.IsGenericType)
|
||||
{
|
||||
// Format the generic type name to something like: GenericOfAgurment1AndArgument2
|
||||
Type genericType = type.GetGenericTypeDefinition();
|
||||
Type[] genericArguments = type.GetGenericArguments();
|
||||
string genericTypeName = genericType.Name;
|
||||
|
||||
// Trim the generic parameter counts from the name
|
||||
genericTypeName = genericTypeName.Substring(0, genericTypeName.IndexOf('`'));
|
||||
string[] argumentTypeNames = genericArguments.Select(t => GetModelName(t)).ToArray();
|
||||
modelName = String.Format(CultureInfo.InvariantCulture, "{0}Of{1}", genericTypeName, String.Join("And", argumentTypeNames));
|
||||
}
|
||||
|
||||
return modelName;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user