Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix newlines

Add gitattributes file, fix newline issues
  • Loading branch information...
commit e51eba2091c5b9342639501533680490d4d1eba2 1 parent 2d95393
@gregmac gregmac authored
View
22 .gitattributes
@@ -0,0 +1,22 @@
+# Auto detect text files and perform LF normalization
+* text=auto
+
+# Custom for Visual Studio
+*.cs diff=csharp
+*.sln merge=union
+*.csproj merge=union
+*.vbproj merge=union
+*.fsproj merge=union
+*.dbproj merge=union
+
+# Standard to msysgit
+*.doc diff=astextplain
+*.DOC diff=astextplain
+*.docx diff=astextplain
+*.DOCX diff=astextplain
+*.dot diff=astextplain
+*.DOT diff=astextplain
+*.pdf diff=astextplain
+*.PDF diff=astextplain
+*.rtf diff=astextplain
+*.RTF diff=astextplain
View
62 Swagger.Net.WebAPI.sln
@@ -1,31 +1,31 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2012
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Swagger.Net", "Swagger.Net\Swagger.Net.csproj", "{23F318E4-D42F-484E-9C5A-41B652145CF0}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7E69DB36-9D7F-4F64-A658-F7CAAB3D2CA9}"
- ProjectSection(SolutionItems) = preProject
- README.md = README.md
- EndProjectSection
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Swagger.Net.WebApi", "Swagger.Net.WebApi\Swagger.Net.WebApi.csproj", "{9598BE25-C0E5-4C40-9926-B11BB757211F}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {23F318E4-D42F-484E-9C5A-41B652145CF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {23F318E4-D42F-484E-9C5A-41B652145CF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {23F318E4-D42F-484E-9C5A-41B652145CF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {23F318E4-D42F-484E-9C5A-41B652145CF0}.Release|Any CPU.Build.0 = Release|Any CPU
- {9598BE25-C0E5-4C40-9926-B11BB757211F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9598BE25-C0E5-4C40-9926-B11BB757211F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9598BE25-C0E5-4C40-9926-B11BB757211F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9598BE25-C0E5-4C40-9926-B11BB757211F}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Swagger.Net", "Swagger.Net\Swagger.Net.csproj", "{23F318E4-D42F-484E-9C5A-41B652145CF0}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7E69DB36-9D7F-4F64-A658-F7CAAB3D2CA9}"
+ ProjectSection(SolutionItems) = preProject
+ README.md = README.md
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Swagger.Net.WebApi", "Swagger.Net.WebApi\Swagger.Net.WebApi.csproj", "{9598BE25-C0E5-4C40-9926-B11BB757211F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {23F318E4-D42F-484E-9C5A-41B652145CF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {23F318E4-D42F-484E-9C5A-41B652145CF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {23F318E4-D42F-484E-9C5A-41B652145CF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {23F318E4-D42F-484E-9C5A-41B652145CF0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9598BE25-C0E5-4C40-9926-B11BB757211F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9598BE25-C0E5-4C40-9926-B11BB757211F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9598BE25-C0E5-4C40-9926-B11BB757211F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9598BE25-C0E5-4C40-9926-B11BB757211F}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
View
140 Swagger.Net/Swagger.Net.csproj
@@ -1,71 +1,71 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{23F318E4-D42F-484E-9C5A-41B652145CF0}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Swagger.Net</RootNamespace>
- <AssemblyName>Swagger.Net</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
- <RestorePackages>true</RestorePackages>
- <TargetFrameworkProfile />
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <Prefer32Bit>false</Prefer32Bit>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <DocumentationFile>bin\Release\Swagger.Net.xml</DocumentationFile>
- <Prefer32Bit>false</Prefer32Bit>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.ComponentModel.DataAnnotations" />
- <Reference Include="System.Core" />
- <Reference Include="System.Data.Entity" />
- <Reference Include="System.Net.Http" />
- <Reference Include="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
- <Reference Include="System.Web" />
- <Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
- <Reference Include="System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
- <Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="SwaggerModels.cs" />
- <Compile Include="SwaggerActionFilter.cs" />
- <Compile Include="SwaggerController.cs" />
- <Compile Include="XmlCommentDocumentationProvider.cs" />
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{23F318E4-D42F-484E-9C5A-41B652145CF0}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Swagger.Net</RootNamespace>
+ <AssemblyName>Swagger.Net</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
+ <TargetFrameworkProfile />
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <DocumentationFile>bin\Release\Swagger.Net.xml</DocumentationFile>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.ComponentModel.DataAnnotations" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Data.Entity" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+ <Reference Include="System.Web" />
+ <Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+ <Reference Include="System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+ <Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="SwaggerModels.cs" />
+ <Compile Include="SwaggerActionFilter.cs" />
+ <Compile Include="SwaggerController.cs" />
+ <Compile Include="XmlCommentDocumentationProvider.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
</Project>
View
330 Swagger.Net/XmlCommentDocumentationProvider.cs
@@ -1,165 +1,165 @@
-using System;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Web.Http.Controllers;
-using System.Web.Http.Description;
-using System.Xml.XPath;
-
-namespace Swagger.Net
-{
- /// <summary>
- /// Accesses the XML doc blocks written in code to further document the API.
- /// All credit goes to: <see cref="http://blogs.msdn.com/b/yaohuang1/archive/2012/05/21/asp-net-web-api-generating-a-web-api-help-page-using-apiexplorer.aspx"/>
- /// </summary>
- public class XmlCommentDocumentationProvider : IDocumentationProvider
- {
- XPathNavigator _documentNavigator;
- private const string _methodExpression = "/doc/members/member[@name='M:{0}']";
- private static Regex nullableTypeNameRegex = new Regex(@"(.*\.Nullable)" + Regex.Escape("`1[[") + "([^,]*),.*");
-
- public XmlCommentDocumentationProvider(string documentPath)
- {
- XPathDocument xpath = new XPathDocument(documentPath);
- _documentNavigator = xpath.CreateNavigator();
- }
-
- public virtual string GetDocumentation(HttpParameterDescriptor parameterDescriptor)
- {
- ReflectedHttpParameterDescriptor reflectedParameterDescriptor = parameterDescriptor as ReflectedHttpParameterDescriptor;
- if (reflectedParameterDescriptor != null)
- {
- XPathNavigator memberNode = GetMemberNode(reflectedParameterDescriptor.ActionDescriptor);
- if (memberNode != null)
- {
- string parameterName = reflectedParameterDescriptor.ParameterInfo.Name;
- XPathNavigator parameterNode = memberNode.SelectSingleNode(string.Format("param[@name='{0}']", parameterName));
- if (parameterNode != null)
- {
- return parameterNode.Value.Trim();
- }
- }
- }
-
- return "No Documentation Found.";
- }
-
- public virtual bool GetRequired(HttpParameterDescriptor parameterDescriptor)
- {
- ReflectedHttpParameterDescriptor reflectedParameterDescriptor = parameterDescriptor as ReflectedHttpParameterDescriptor;
- if (reflectedParameterDescriptor != null)
- {
- return !reflectedParameterDescriptor.ParameterInfo.IsOptional;
- }
-
- return true;
- }
-
- public virtual string GetDocumentation(HttpActionDescriptor actionDescriptor)
- {
- XPathNavigator memberNode = GetMemberNode(actionDescriptor);
- if (memberNode != null)
- {
- XPathNavigator summaryNode = memberNode.SelectSingleNode("summary");
- if (summaryNode != null)
- {
- return summaryNode.Value.Trim();
- }
- }
-
- return "No Documentation Found.";
- }
-
- public virtual string GetNotes(HttpActionDescriptor actionDescriptor)
- {
- XPathNavigator memberNode = GetMemberNode(actionDescriptor);
- if (memberNode != null)
- {
- XPathNavigator summaryNode = memberNode.SelectSingleNode("remarks");
- if (summaryNode != null)
- {
- return summaryNode.Value.Trim();
- }
- }
-
- return "No Documentation Found.";
- }
-
- public virtual string GetResponseClass(HttpActionDescriptor actionDescriptor)
- {
- ReflectedHttpActionDescriptor reflectedActionDescriptor = actionDescriptor as ReflectedHttpActionDescriptor;
- if (reflectedActionDescriptor != null)
- {
- if (reflectedActionDescriptor.MethodInfo.ReturnType.IsGenericType)
- {
- StringBuilder sb = new StringBuilder(reflectedActionDescriptor.MethodInfo.ReturnParameter.ParameterType.Name);
- sb.Append("<");
- Type[] types = reflectedActionDescriptor.MethodInfo.ReturnParameter.ParameterType.GetGenericArguments();
- for(int i = 0; i < types.Length; i++)
- {
- sb.Append(types[i].Name);
- if(i != (types.Length - 1)) sb.Append(", ");
- }
- sb.Append(">");
- return sb.Replace("`1","").ToString();
- }
- else
- return reflectedActionDescriptor.MethodInfo.ReturnType.Name;
- }
-
- return "void";
- }
-
- public virtual string GetNickname(HttpActionDescriptor actionDescriptor)
- {
- ReflectedHttpActionDescriptor reflectedActionDescriptor = actionDescriptor as ReflectedHttpActionDescriptor;
- if (reflectedActionDescriptor != null)
- {
- return reflectedActionDescriptor.MethodInfo.Name;
- }
-
- return "NicknameNotFound";
- }
-
- private XPathNavigator GetMemberNode(HttpActionDescriptor actionDescriptor)
- {
- ReflectedHttpActionDescriptor reflectedActionDescriptor = actionDescriptor as ReflectedHttpActionDescriptor;
- if (reflectedActionDescriptor != null)
- {
- string selectExpression = string.Format(_methodExpression, GetMemberName(reflectedActionDescriptor.MethodInfo));
- XPathNavigator node = _documentNavigator.SelectSingleNode(selectExpression);
- if (node != null)
- {
- return node;
- }
- }
-
- return null;
- }
-
- private static string GetMemberName(MethodInfo method)
- {
- string name = string.Format("{0}.{1}", method.DeclaringType.FullName, method.Name);
- var parameters = method.GetParameters();
- if (parameters.Length != 0)
- {
- string[] parameterTypeNames = parameters.Select(param => ProcessTypeName(param.ParameterType.FullName)).ToArray();
- name += string.Format("({0})", string.Join(",", parameterTypeNames));
- }
-
- return name;
- }
-
- private static string ProcessTypeName(string typeName)
- {
- //handle nullable
- var result = nullableTypeNameRegex.Match(typeName);
- if (result.Success)
- {
- return string.Format("{0}{{{1}}}", result.Groups[1].Value, result.Groups[2].Value);
- }
- return typeName;
- }
- }
-}
+using System;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Web.Http.Controllers;
+using System.Web.Http.Description;
+using System.Xml.XPath;
+
+namespace Swagger.Net
+{
+ /// <summary>
+ /// Accesses the XML doc blocks written in code to further document the API.
+ /// All credit goes to: <see cref="http://blogs.msdn.com/b/yaohuang1/archive/2012/05/21/asp-net-web-api-generating-a-web-api-help-page-using-apiexplorer.aspx"/>
+ /// </summary>
+ public class XmlCommentDocumentationProvider : IDocumentationProvider
+ {
+ XPathNavigator _documentNavigator;
+ private const string _methodExpression = "/doc/members/member[@name='M:{0}']";
+ private static Regex nullableTypeNameRegex = new Regex(@"(.*\.Nullable)" + Regex.Escape("`1[[") + "([^,]*),.*");
+
+ public XmlCommentDocumentationProvider(string documentPath)
+ {
+ XPathDocument xpath = new XPathDocument(documentPath);
+ _documentNavigator = xpath.CreateNavigator();
+ }
+
+ public virtual string GetDocumentation(HttpParameterDescriptor parameterDescriptor)
+ {
+ ReflectedHttpParameterDescriptor reflectedParameterDescriptor = parameterDescriptor as ReflectedHttpParameterDescriptor;
+ if (reflectedParameterDescriptor != null)
+ {
+ XPathNavigator memberNode = GetMemberNode(reflectedParameterDescriptor.ActionDescriptor);
+ if (memberNode != null)
+ {
+ string parameterName = reflectedParameterDescriptor.ParameterInfo.Name;
+ XPathNavigator parameterNode = memberNode.SelectSingleNode(string.Format("param[@name='{0}']", parameterName));
+ if (parameterNode != null)
+ {
+ return parameterNode.Value.Trim();
+ }
+ }
+ }
+
+ return "No Documentation Found.";
+ }
+
+ public virtual bool GetRequired(HttpParameterDescriptor parameterDescriptor)
+ {
+ ReflectedHttpParameterDescriptor reflectedParameterDescriptor = parameterDescriptor as ReflectedHttpParameterDescriptor;
+ if (reflectedParameterDescriptor != null)
+ {
+ return !reflectedParameterDescriptor.ParameterInfo.IsOptional;
+ }
+
+ return true;
+ }
+
+ public virtual string GetDocumentation(HttpActionDescriptor actionDescriptor)
+ {
+ XPathNavigator memberNode = GetMemberNode(actionDescriptor);
+ if (memberNode != null)
+ {
+ XPathNavigator summaryNode = memberNode.SelectSingleNode("summary");
+ if (summaryNode != null)
+ {
+ return summaryNode.Value.Trim();
+ }
+ }
+
+ return "No Documentation Found.";
+ }
+
+ public virtual string GetNotes(HttpActionDescriptor actionDescriptor)
+ {
+ XPathNavigator memberNode = GetMemberNode(actionDescriptor);
+ if (memberNode != null)
+ {
+ XPathNavigator summaryNode = memberNode.SelectSingleNode("remarks");
+ if (summaryNode != null)
+ {
+ return summaryNode.Value.Trim();
+ }
+ }
+
+ return "No Documentation Found.";
+ }
+
+ public virtual string GetResponseClass(HttpActionDescriptor actionDescriptor)
+ {
+ ReflectedHttpActionDescriptor reflectedActionDescriptor = actionDescriptor as ReflectedHttpActionDescriptor;
+ if (reflectedActionDescriptor != null)
+ {
+ if (reflectedActionDescriptor.MethodInfo.ReturnType.IsGenericType)
+ {
+ StringBuilder sb = new StringBuilder(reflectedActionDescriptor.MethodInfo.ReturnParameter.ParameterType.Name);
+ sb.Append("<");
+ Type[] types = reflectedActionDescriptor.MethodInfo.ReturnParameter.ParameterType.GetGenericArguments();
+ for(int i = 0; i < types.Length; i++)
+ {
+ sb.Append(types[i].Name);
+ if(i != (types.Length - 1)) sb.Append(", ");
+ }
+ sb.Append(">");
+ return sb.Replace("`1","").ToString();
+ }
+ else
+ return reflectedActionDescriptor.MethodInfo.ReturnType.Name;
+ }
+
+ return "void";
+ }
+
+ public virtual string GetNickname(HttpActionDescriptor actionDescriptor)
+ {
+ ReflectedHttpActionDescriptor reflectedActionDescriptor = actionDescriptor as ReflectedHttpActionDescriptor;
+ if (reflectedActionDescriptor != null)
+ {
+ return reflectedActionDescriptor.MethodInfo.Name;
+ }
+
+ return "NicknameNotFound";
+ }
+
+ private XPathNavigator GetMemberNode(HttpActionDescriptor actionDescriptor)
+ {
+ ReflectedHttpActionDescriptor reflectedActionDescriptor = actionDescriptor as ReflectedHttpActionDescriptor;
+ if (reflectedActionDescriptor != null)
+ {
+ string selectExpression = string.Format(_methodExpression, GetMemberName(reflectedActionDescriptor.MethodInfo));
+ XPathNavigator node = _documentNavigator.SelectSingleNode(selectExpression);
+ if (node != null)
+ {
+ return node;
+ }
+ }
+
+ return null;
+ }
+
+ private static string GetMemberName(MethodInfo method)
+ {
+ string name = string.Format("{0}.{1}", method.DeclaringType.FullName, method.Name);
+ var parameters = method.GetParameters();
+ if (parameters.Length != 0)
+ {
+ string[] parameterTypeNames = parameters.Select(param => ProcessTypeName(param.ParameterType.FullName)).ToArray();
+ name += string.Format("({0})", string.Join(",", parameterTypeNames));
+ }
+
+ return name;
+ }
+
+ private static string ProcessTypeName(string typeName)
+ {
+ //handle nullable
+ var result = nullableTypeNameRegex.Match(typeName);
+ if (result.Success)
+ {
+ return string.Format("{0}{{{1}}}", result.Groups[1].Value, result.Groups[2].Value);
+ }
+ return typeName;
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.