Imports System.Collections.Generic Imports System.Collections.ObjectModel Imports System.Net.Http.Headers Imports System.Web.Http.Description Imports $rootnamespace$.Areas.HelpPage.ModelDescriptions Namespace Areas.HelpPage.Models ''' ''' The model that represents an API displayed on the help page. ''' Public Class HelpPageApiModel Private _sampleRequests As IDictionary(Of MediaTypeHeaderValue, Object) Private _sampleResponses As IDictionary(Of MediaTypeHeaderValue, Object) Private _errorMessages As Collection(Of String) Private _apiDescription As ApiDescription Private _uriParameters As Collection(Of ParameterDescription) Private _requestModelDescription As ModelDescription Private _resourceDescription As ModelDescription Private _requestDocumentation As String ''' ''' Initializes a new instance of the class. ''' Public Sub New() UriParameters = New Collection(Of ParameterDescription) SampleRequests = New Dictionary(Of MediaTypeHeaderValue, Object) SampleResponses = New Dictionary(Of MediaTypeHeaderValue, Object) ErrorMessages = New Collection(Of String) End Sub ''' ''' Gets or sets the that describes the API. ''' Public Property ApiDescription As ApiDescription Get Return _apiDescription End Get Set(value As ApiDescription) _apiDescription = value End Set End Property ''' ''' Gets or sets the collection that describes the URI parameters for the API. ''' Public Property UriParameters() As Collection(Of ParameterDescription) Get Return _uriParameters End Get Private Set(value As Collection(Of ParameterDescription)) _uriParameters = value End Set End Property ''' ''' Gets or sets the documentation for the request. ''' Public Property RequestDocumentation() As String Get Return _requestDocumentation End Get Set(value As String) _requestDocumentation = value End Set End Property ''' ''' Gets or sets the model description of the request body. ''' Public Property RequestModelDescription() As ModelDescription Get Return _requestModelDescription End Get Set(value As ModelDescription) _requestModelDescription = value End Set End Property ''' ''' Gets the request body parameter descriptions. ''' Public ReadOnly Property RequestBodyParameters() As IList(Of ParameterDescription) Get Return GetParameterDescriptions(RequestModelDescription) End Get End Property ''' ''' Gets or sets the that describes the resource. ''' Public Property ResourceDescription() As ModelDescription Get Return _resourceDescription End Get Set(value As ModelDescription) _resourceDescription = value End Set End Property ''' ''' Gets the resource property descriptions. ''' Public ReadOnly Property ResourceProperties() As IList(Of ParameterDescription) Get Return GetParameterDescriptions(ResourceDescription) End Get End Property ''' ''' Gets the sample requests associated with the API. ''' Public Property SampleRequests As IDictionary(Of MediaTypeHeaderValue, Object) Get Return _sampleRequests End Get Private Set(value As IDictionary(Of MediaTypeHeaderValue, Object)) _sampleRequests = value End Set End Property ''' ''' Gets the sample responses associated with the API. ''' Public Property SampleResponses As IDictionary(Of MediaTypeHeaderValue, Object) Get Return _sampleResponses End Get Private Set(value As IDictionary(Of MediaTypeHeaderValue, Object)) _sampleResponses = value End Set End Property ''' ''' Gets the error messages associated with this model. ''' Public Property ErrorMessages As Collection(Of String) Get Return _errorMessages End Get Private Set(value As Collection(Of String)) _errorMessages = value End Set End Property Private Shared Function GetParameterDescriptions(modelDescription As ModelDescription) As IList(Of ParameterDescription) Dim complexTypeModelDescription As ComplexTypeModelDescription = TryCast(modelDescription, ComplexTypeModelDescription) If complexTypeModelDescription IsNot Nothing Then Return complexTypeModelDescription.Properties End If Dim collectionModelDescription As CollectionModelDescription = TryCast(modelDescription, CollectionModelDescription) If collectionModelDescription IsNot Nothing Then complexTypeModelDescription = TryCast(collectionModelDescription.ElementDescription, ComplexTypeModelDescription) If complexTypeModelDescription IsNot Nothing Then Return complexTypeModelDescription.Properties End If End If Return Nothing End Function End Class End Namespace