├── .gitattributes ├── .gitignore ├── PublishScripts ├── AzureWebsitePublishModule.psm1 ├── Configurations │ └── XamarinWebAPI-WAWS-dev.json └── Publish-WebApplicationWebsite.ps1 ├── README.md ├── XamarinWebAPI.sln ├── XamarinWebAPI ├── App_Start │ ├── BundleConfig.cs │ ├── FilterConfig.cs │ ├── IdentityConfig.cs │ ├── RouteConfig.cs │ ├── Startup.Auth.cs │ └── WebApiConfig.cs ├── Areas │ └── HelpPage │ │ ├── ApiDescriptionExtensions.cs │ │ ├── App_Start │ │ └── HelpPageConfig.cs │ │ ├── Controllers │ │ └── HelpController.cs │ │ ├── HelpPage.css │ │ ├── HelpPageAreaRegistration.cs │ │ ├── HelpPageConfigurationExtensions.cs │ │ ├── ModelDescriptions │ │ ├── CollectionModelDescription.cs │ │ ├── ComplexTypeModelDescription.cs │ │ ├── DictionaryModelDescription.cs │ │ ├── EnumTypeModelDescription.cs │ │ ├── EnumValueDescription.cs │ │ ├── IModelDocumentationProvider.cs │ │ ├── KeyValuePairModelDescription.cs │ │ ├── ModelDescription.cs │ │ ├── ModelDescriptionGenerator.cs │ │ ├── ModelNameAttribute.cs │ │ ├── ModelNameHelper.cs │ │ ├── ParameterAnnotation.cs │ │ ├── ParameterDescription.cs │ │ └── SimpleTypeModelDescription.cs │ │ ├── Models │ │ └── HelpPageApiModel.cs │ │ ├── SampleGeneration │ │ ├── HelpPageSampleGenerator.cs │ │ ├── HelpPageSampleKey.cs │ │ ├── ImageSample.cs │ │ ├── InvalidSample.cs │ │ ├── ObjectGenerator.cs │ │ ├── SampleDirection.cs │ │ └── TextSample.cs │ │ ├── Views │ │ ├── Help │ │ │ ├── Api.cshtml │ │ │ ├── DisplayTemplates │ │ │ │ ├── ApiGroup.cshtml │ │ │ │ ├── CollectionModelDescription.cshtml │ │ │ │ ├── ComplexTypeModelDescription.cshtml │ │ │ │ ├── DictionaryModelDescription.cshtml │ │ │ │ ├── EnumTypeModelDescription.cshtml │ │ │ │ ├── HelpPageApiModel.cshtml │ │ │ │ ├── ImageSample.cshtml │ │ │ │ ├── InvalidSample.cshtml │ │ │ │ ├── KeyValuePairModelDescription.cshtml │ │ │ │ ├── ModelDescriptionLink.cshtml │ │ │ │ ├── Parameters.cshtml │ │ │ │ ├── Samples.cshtml │ │ │ │ ├── SimpleTypeModelDescription.cshtml │ │ │ │ └── TextSample.cshtml │ │ │ ├── Index.cshtml │ │ │ └── ResourceModel.cshtml │ │ ├── Shared │ │ │ └── _Layout.cshtml │ │ ├── Web.config │ │ └── _ViewStart.cshtml │ │ └── XmlDocumentationProvider.cs ├── Content │ ├── Site.css │ ├── bootstrap.css │ └── bootstrap.min.css ├── Controllers │ ├── AccountController.cs │ ├── ApiPersonController.cs │ ├── HomeController.cs │ ├── PersonController.cs │ └── ValuesController.cs ├── Global.asax ├── Global.asax.cs ├── Models │ ├── AccountBindingModels.cs │ ├── AccountViewModels.cs │ ├── IdentityModels.cs │ └── Person.cs ├── Project_Readme.html ├── Properties │ └── AssemblyInfo.cs ├── Providers │ └── ApplicationOAuthProvider.cs ├── Results │ └── ChallengeResult.cs ├── Scripts │ ├── _references.js │ ├── bootstrap.js │ ├── bootstrap.min.js │ ├── jquery-1.10.2.intellisense.js │ ├── jquery-1.10.2.js │ ├── jquery-1.10.2.min.js │ ├── jquery-1.10.2.min.map │ ├── jquery.validate-vsdoc.js │ ├── jquery.validate.js │ ├── jquery.validate.min.js │ ├── jquery.validate.unobtrusive.js │ ├── jquery.validate.unobtrusive.min.js │ ├── modernizr-2.6.2.js │ ├── respond.js │ └── respond.min.js ├── Startup.cs ├── Views │ ├── Home │ │ └── Index.cshtml │ ├── Person │ │ ├── Create.cshtml │ │ ├── Delete.cshtml │ │ ├── Details.cshtml │ │ ├── Edit.cshtml │ │ └── Index.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ └── _Layout.cshtml │ ├── Web.config │ └── _ViewStart.cshtml ├── Web.Debug.config ├── Web.Release.config ├── Web.config ├── XamarinWebAPI.csproj ├── favicon.ico ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ └── glyphicons-halflings-regular.woff └── packages.config └── Xamarin_Web_API_iOS ├── Components ├── restsharp-104.1.0.info ├── restsharp-104.1.0.png ├── restsharp-104.1.0 │ └── lib │ │ └── ios │ │ └── RestSharp.MonoTouch.dll ├── restsharp-105.0.1.0.info ├── restsharp-105.0.1.0.png └── restsharp-105.0.1.0 │ ├── component │ ├── Details.md │ ├── GettingStarted.md │ ├── License.md │ ├── Manifest.xml │ └── icons │ │ └── restsharp_128x128.png │ ├── lib │ ├── android │ │ └── RestSharp.MonoDroid.dll │ ├── ios-unified │ │ └── RestSharp.MonoTouch.dll │ └── ios │ │ └── RestSharp.MonoTouch.dll │ └── samples │ ├── RestSharp.Android.Sample │ ├── MainActivity.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Resources │ │ ├── Drawable │ │ │ └── Icon.png │ │ ├── Layout │ │ │ └── Main.axml │ │ ├── Resource.Designer.cs │ │ └── Values │ │ │ └── Strings.xml │ ├── RestSharp.Android.Sample.csproj │ └── RestSharp.Android.Sample.sln │ ├── RestSharp.iOS.Sample-Classic │ ├── AppDelegate.cs │ ├── Default-568h@2x.png │ ├── Info.plist │ ├── Main.cs │ ├── RequestViewController.cs │ ├── RestSharp.iOS.Sample-Classic.sln │ └── RestSharp.iOS.Sample-classic.csproj │ └── RestSharp.iOS.Sample │ ├── AppDelegate.cs │ ├── Default-568h@2x.png │ ├── Info.plist │ ├── Main.cs │ ├── RequestViewController.cs │ ├── RestSharp.iOS.Sample.csproj │ └── RestSharp.iOS.Sample.sln ├── WebAPI ├── App.csproj ├── AppDelegate.cs ├── HomeScreen.cs ├── Info.plist ├── Main.cs ├── Person.cs └── TableSource.cs └── XamarinWebAPI.sln /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studo 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | #NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | *_i.c 42 | *_p.c 43 | *_i.h 44 | *.ilk 45 | *.meta 46 | *.obj 47 | *.pch 48 | *.pdb 49 | *.pgc 50 | *.pgd 51 | *.rsp 52 | *.sbr 53 | *.tlb 54 | *.tli 55 | *.tlh 56 | *.tmp 57 | *.tmp_proj 58 | *.log 59 | *.vspscc 60 | *.vssscc 61 | .builds 62 | *.pidb 63 | *.svclog 64 | *.scc 65 | 66 | # Chutzpah Test files 67 | _Chutzpah* 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | *.cachefile 76 | 77 | # Visual Studio profiler 78 | *.psess 79 | *.vsp 80 | *.vspx 81 | 82 | # TFS 2012 Local Workspace 83 | $tf/ 84 | 85 | # Guidance Automation Toolkit 86 | *.gpState 87 | 88 | # ReSharper is a .NET coding add-in 89 | _ReSharper*/ 90 | *.[Rr]e[Ss]harper 91 | *.DotSettings.user 92 | 93 | # JustCode is a .NET coding addin-in 94 | .JustCode 95 | 96 | # TeamCity is a build add-in 97 | _TeamCity* 98 | 99 | # DotCover is a Code Coverage Tool 100 | *.dotCover 101 | 102 | # NCrunch 103 | _NCrunch_* 104 | .*crunch*.local.xml 105 | 106 | # MightyMoose 107 | *.mm.* 108 | AutoTest.Net/ 109 | 110 | # Web workbench (sass) 111 | .sass-cache/ 112 | 113 | # Installshield output folder 114 | [Ee]xpress/ 115 | 116 | # DocProject is a documentation generator add-in 117 | DocProject/buildhelp/ 118 | DocProject/Help/*.HxT 119 | DocProject/Help/*.HxC 120 | DocProject/Help/*.hhc 121 | DocProject/Help/*.hhk 122 | DocProject/Help/*.hhp 123 | DocProject/Help/Html2 124 | DocProject/Help/html 125 | 126 | # Click-Once directory 127 | publish/ 128 | 129 | # Publish Web Output 130 | *.[Pp]ublish.xml 131 | *.azurePubxml 132 | # TODO: Comment the next line if you want to checkin your web deploy settings 133 | # but database connection strings (with potential passwords) will be unencrypted 134 | *.pubxml 135 | *.publishproj 136 | 137 | # NuGet Packages 138 | *.nupkg 139 | # The packages folder can be ignored because of Package Restore 140 | **/packages/* 141 | # except build/, which is used as an MSBuild target. 142 | !**/packages/build/ 143 | # Uncomment if necessary however generally it will be regenerated when needed 144 | #!**/packages/repositories.config 145 | 146 | # Windows Azure Build Output 147 | csx/ 148 | *.build.csdef 149 | 150 | # Windows Store app package directory 151 | AppPackages/ 152 | 153 | # Others 154 | *.[Cc]ache 155 | ClientBin/ 156 | [Ss]tyle[Cc]op.* 157 | ~$* 158 | *~ 159 | *.dbmdl 160 | *.dbproj.schemaview 161 | *.pfx 162 | *.publishsettings 163 | node_modules/ 164 | bower_components/ 165 | 166 | # RIA/Silverlight projects 167 | Generated_Code/ 168 | 169 | # Backup & report files from converting an old project file 170 | # to a newer Visual Studio version. Backup files are not needed, 171 | # because we have git ;-) 172 | _UpgradeReport_Files/ 173 | Backup*/ 174 | UpgradeLog*.XML 175 | UpgradeLog*.htm 176 | 177 | # SQL Server files 178 | *.mdf 179 | *.ldf 180 | 181 | # Business Intelligence projects 182 | *.rdl.data 183 | *.bim.layout 184 | *.bim_*.settings 185 | 186 | # Microsoft Fakes 187 | FakesAssemblies/ 188 | 189 | # Node.js Tools for Visual Studio 190 | .ntvs_analysis.dat 191 | 192 | # Visual Studio 6 build log 193 | *.plg 194 | 195 | # Visual Studio 6 workspace options file 196 | *.opt -------------------------------------------------------------------------------- /PublishScripts/Configurations/XamarinWebAPI-WAWS-dev.json: -------------------------------------------------------------------------------- 1 | { 2 | "environmentSettings": { 3 | "webSite": { 4 | "name": "XamarinWebAPI", 5 | "location": "East US 2" 6 | }, 7 | "databases": [ 8 | { 9 | "connectionStringName": "DefaultConnection", 10 | "databaseName": "XamarinWebAPI_db", 11 | "serverName": "", 12 | "user": "DB_XamarinWebAPI", 13 | "password": "", 14 | "edition": "", 15 | "size": "", 16 | "collation": "", 17 | "location": "Southeast Asia" 18 | } 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /PublishScripts/Publish-WebApplicationWebsite.ps1: -------------------------------------------------------------------------------- 1 | #Requires -Version 3.0 2 | 3 | <# 4 | .SYNOPSIS 5 | Creates and deploys a Microsoft Azure Website for a Visual Studio web project. 6 | For more detailed documentation go to: http://go.microsoft.com/fwlink/?LinkID=394471 7 | 8 | .EXAMPLE 9 | PS C:\> .\Publish-WebApplicationWebSite.ps1 ` 10 | -Configuration .\Configurations\WebApplication1-WAWS-dev.json ` 11 | -WebDeployPackage ..\WebApplication1\WebApplication1.zip ` 12 | -Verbose 13 | 14 | #> 15 | [CmdletBinding(HelpUri = 'http://go.microsoft.com/fwlink/?LinkID=391696')] 16 | param 17 | ( 18 | [Parameter(Mandatory = $true)] 19 | [ValidateScript({Test-Path $_ -PathType Leaf})] 20 | [String] 21 | $Configuration, 22 | 23 | [Parameter(Mandatory = $false)] 24 | [String] 25 | $SubscriptionName, 26 | 27 | [Parameter(Mandatory = $false)] 28 | [ValidateScript({Test-Path $_ -PathType Leaf})] 29 | [String] 30 | $WebDeployPackage, 31 | 32 | [Parameter(Mandatory = $false)] 33 | [ValidateScript({ !($_ | Where-Object { !$_.Contains('Name') -or !$_.Contains('Password')}) })] 34 | [Hashtable[]] 35 | $DatabaseServerPassword, 36 | 37 | [Parameter(Mandatory = $false)] 38 | [Switch] 39 | $SendHostMessagesToOutput = $false 40 | ) 41 | 42 | 43 | function New-WebDeployPackage 44 | { 45 | #Write a function to build and package your web application 46 | 47 | #To build your web application, use MsBuild.exe. For help, see MSBuild Command-Line Reference at: http://go.microsoft.com/fwlink/?LinkId=391339 48 | } 49 | 50 | function Test-WebApplication 51 | { 52 | #Edit this function to run unit tests on your web application 53 | 54 | #Write a function to run unit tests on your web application, use VSTest.Console.exe. For help, see VSTest.Console Command-Line Reference at http://go.microsoft.com/fwlink/?LinkId=391340 55 | } 56 | 57 | function New-AzureWebApplicationWebsiteEnvironment 58 | { 59 | [CmdletBinding()] 60 | param 61 | ( 62 | [Parameter(Mandatory = $true)] 63 | [Object] 64 | $Configuration, 65 | 66 | [Parameter (Mandatory = $false)] 67 | [AllowNull()] 68 | [Hashtable[]] 69 | $DatabaseServerPassword 70 | ) 71 | 72 | Add-AzureWebsite -Name $Config.name -Location $Config.location | Out-String | Write-HostWithTime 73 | # Create the SQL databases. The connection string is used for deployment. 74 | $connectionString = New-Object -TypeName Hashtable 75 | 76 | if ($Config.Contains('databases')) 77 | { 78 | @($Config.databases) | 79 | Where-Object {$_.connectionStringName -ne ''} | 80 | Add-AzureSQLDatabases -DatabaseServerPassword $DatabaseServerPassword -CreateDatabase | 81 | ForEach-Object { $connectionString.Add($_.Name, $_.ConnectionString) } 82 | } 83 | 84 | return @{ConnectionString = $connectionString} 85 | } 86 | 87 | function Publish-AzureWebApplicationToWebsite 88 | { 89 | [CmdletBinding()] 90 | param 91 | ( 92 | [Parameter(Mandatory = $true)] 93 | [Object] 94 | $Configuration, 95 | 96 | [Parameter(Mandatory = $false)] 97 | [AllowNull()] 98 | [Hashtable] 99 | $ConnectionString, 100 | 101 | [Parameter(Mandatory = $true)] 102 | [ValidateScript({Test-Path $_ -PathType Leaf})] 103 | [String] 104 | $WebDeployPackage 105 | ) 106 | 107 | if ($ConnectionString -and $ConnectionString.Count -gt 0) 108 | { 109 | Publish-AzureWebsiteProject ` 110 | -Name $Config.name ` 111 | -Package $WebDeployPackage ` 112 | -ConnectionString $ConnectionString 113 | } 114 | else 115 | { 116 | Publish-AzureWebsiteProject ` 117 | -Name $Config.name ` 118 | -Package $WebDeployPackage 119 | } 120 | } 121 | 122 | 123 | # Script main routine 124 | Set-StrictMode -Version 3 125 | 126 | Remove-Module AzureWebSitePublishModule -ErrorAction SilentlyContinue 127 | $scriptDirectory = Split-Path -Parent $PSCmdlet.MyInvocation.MyCommand.Definition 128 | Import-Module ($scriptDirectory + '\AzureWebSitePublishModule.psm1') -Scope Local -Verbose:$false 129 | 130 | New-Variable -Name VMWebDeployWaitTime -Value 30 -Option Constant -Scope Script 131 | New-Variable -Name AzureWebAppPublishOutput -Value @() -Scope Global -Force 132 | New-Variable -Name SendHostMessagesToOutput -Value $SendHostMessagesToOutput -Scope Global -Force 133 | 134 | try 135 | { 136 | $originalErrorActionPreference = $Global:ErrorActionPreference 137 | $originalVerbosePreference = $Global:VerbosePreference 138 | 139 | if ($PSBoundParameters['Verbose']) 140 | { 141 | $Global:VerbosePreference = 'Continue' 142 | } 143 | 144 | $scriptName = $MyInvocation.MyCommand.Name + ':' 145 | 146 | Write-VerboseWithTime ($scriptName + ' Start') 147 | 148 | $Global:ErrorActionPreference = 'Stop' 149 | Write-VerboseWithTime ('{0} $ErrorActionPreference is set to {1}' -f $scriptName, $ErrorActionPreference) 150 | 151 | Write-Debug ('{0}: $PSCmdlet.ParameterSetName = {1}' -f $scriptName, $PSCmdlet.ParameterSetName) 152 | 153 | # Save the current subscription. It will be restored to Current status later in the script 154 | Backup-Subscription -UserSpecifiedSubscription $SubscriptionName 155 | 156 | # Verify that you have the Azure module, Version 0.7.4 or later. 157 | if (-not (Test-AzureModule)) 158 | { 159 | throw 'You have an outdated version of Microsoft Azure PowerShell. To install the latest version, go to http://go.microsoft.com/fwlink/?LinkID=320552 .' 160 | } 161 | 162 | if ($SubscriptionName) 163 | { 164 | 165 | # If you provided a subscription name, verify that the subscription exists in your account. 166 | if (!(Get-AzureSubscription -SubscriptionName $SubscriptionName)) 167 | { 168 | throw ("{0}: Cannot find the subscription name $SubscriptionName" -f $scriptName) 169 | 170 | } 171 | 172 | # Set the specified subscription to current. 173 | Select-AzureSubscription -SubscriptionName $SubscriptionName | Out-Null 174 | 175 | Write-VerboseWithTime ('{0}: Subscription is set to {1}' -f $scriptName, $SubscriptionName) 176 | } 177 | 178 | $Config = Read-ConfigFile $Configuration 179 | 180 | #Build and package your web application 181 | New-WebDeployPackage 182 | 183 | #Run unit tests on your web application 184 | Test-WebApplication 185 | 186 | #Create Azure environment described in the JSON configuration file 187 | $newEnvironmentResult = New-AzureWebApplicationWebsiteEnvironment -Configuration $Config -DatabaseServerPassword $DatabaseServerPassword 188 | 189 | #Deploy Web Application package if $WebDeployPackage is specified by the user 190 | if($WebDeployPackage) 191 | { 192 | Publish-AzureWebApplicationToWebsite ` 193 | -Configuration $Config ` 194 | -ConnectionString $newEnvironmentResult.ConnectionString ` 195 | -WebDeployPackage $WebDeployPackage 196 | } 197 | } 198 | finally 199 | { 200 | $Global:ErrorActionPreference = $originalErrorActionPreference 201 | $Global:VerbosePreference = $originalVerbosePreference 202 | 203 | # Restore the original current subscription to Current status 204 | Restore-Subscription 205 | 206 | Write-Output $Global:AzureWebAppPublishOutput 207 | $Global:AzureWebAppPublishOutput = @() 208 | } 209 | -------------------------------------------------------------------------------- /XamarinWebAPI.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamarinWebAPI", "XamarinWebAPI\XamarinWebAPI.csproj", "{72F98678-A8B2-4CA5-9203-834111EB3EA7}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PublishScripts", "PublishScripts", "{49F7D2A2-372A-436B-A57B-08D6E6FA5169}" 9 | ProjectSection(SolutionItems) = preProject 10 | PublishScripts\AzureWebsitePublishModule.psm1 = PublishScripts\AzureWebsitePublishModule.psm1 11 | PublishScripts\Publish-WebApplicationWebsite.ps1 = PublishScripts\Publish-WebApplicationWebsite.ps1 12 | EndProjectSection 13 | EndProject 14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Configurations", "Configurations", "{EA35987B-32E8-470B-B698-513DC5C1B96E}" 15 | ProjectSection(SolutionItems) = preProject 16 | PublishScripts\Configurations\XamarinWebAPI-WAWS-dev.json = PublishScripts\Configurations\XamarinWebAPI-WAWS-dev.json 17 | EndProjectSection 18 | EndProject 19 | Global 20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 21 | Debug|Any CPU = Debug|Any CPU 22 | Release|Any CPU = Release|Any CPU 23 | EndGlobalSection 24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 25 | {72F98678-A8B2-4CA5-9203-834111EB3EA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {72F98678-A8B2-4CA5-9203-834111EB3EA7}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {72F98678-A8B2-4CA5-9203-834111EB3EA7}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {72F98678-A8B2-4CA5-9203-834111EB3EA7}.Release|Any CPU.Build.0 = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(SolutionProperties) = preSolution 31 | HideSolutionNode = FALSE 32 | EndGlobalSection 33 | GlobalSection(NestedProjects) = preSolution 34 | {EA35987B-32E8-470B-B698-513DC5C1B96E} = {49F7D2A2-372A-436B-A57B-08D6E6FA5169} 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /XamarinWebAPI/App_Start/BundleConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Optimization; 3 | 4 | namespace XamarinWebAPI 5 | { 6 | public class BundleConfig 7 | { 8 | // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862 9 | public static void RegisterBundles(BundleCollection bundles) 10 | { 11 | bundles.Add(new ScriptBundle("~/bundles/jquery").Include( 12 | "~/Scripts/jquery-{version}.js")); 13 | 14 | // Use the development version of Modernizr to develop with and learn from. Then, when you're 15 | // ready for production, use the build tool at http://modernizr.com to pick only the tests you need. 16 | bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( 17 | "~/Scripts/modernizr-*")); 18 | 19 | bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( 20 | "~/Scripts/bootstrap.js", 21 | "~/Scripts/respond.js")); 22 | 23 | bundles.Add(new StyleBundle("~/Content/css").Include( 24 | "~/Content/bootstrap.css", 25 | "~/Content/site.css")); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /XamarinWebAPI/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Mvc; 3 | 4 | namespace XamarinWebAPI 5 | { 6 | public class FilterConfig 7 | { 8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 9 | { 10 | filters.Add(new HandleErrorAttribute()); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /XamarinWebAPI/App_Start/IdentityConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Microsoft.AspNet.Identity; 3 | using Microsoft.AspNet.Identity.EntityFramework; 4 | using Microsoft.AspNet.Identity.Owin; 5 | using Microsoft.Owin; 6 | using XamarinWebAPI.Models; 7 | 8 | namespace XamarinWebAPI 9 | { 10 | // Configure the application user manager used in this application. UserManager is defined in ASP.NET Identity and is used by the application. 11 | 12 | public class ApplicationUserManager : UserManager 13 | { 14 | public ApplicationUserManager(IUserStore store) 15 | : base(store) 16 | { 17 | } 18 | 19 | public static ApplicationUserManager Create(IdentityFactoryOptions options, IOwinContext context) 20 | { 21 | var manager = new ApplicationUserManager(new UserStore(context.Get())); 22 | // Configure validation logic for usernames 23 | manager.UserValidator = new UserValidator(manager) 24 | { 25 | AllowOnlyAlphanumericUserNames = false, 26 | RequireUniqueEmail = true 27 | }; 28 | // Configure validation logic for passwords 29 | manager.PasswordValidator = new PasswordValidator 30 | { 31 | RequiredLength = 6, 32 | RequireNonLetterOrDigit = true, 33 | RequireDigit = true, 34 | RequireLowercase = true, 35 | RequireUppercase = true, 36 | }; 37 | var dataProtectionProvider = options.DataProtectionProvider; 38 | if (dataProtectionProvider != null) 39 | { 40 | manager.UserTokenProvider = new DataProtectorTokenProvider(dataProtectionProvider.Create("ASP.NET Identity")); 41 | } 42 | return manager; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /XamarinWebAPI/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace XamarinWebAPI 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{id}", 19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /XamarinWebAPI/App_Start/Startup.Auth.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Microsoft.AspNet.Identity; 5 | using Microsoft.AspNet.Identity.EntityFramework; 6 | using Microsoft.Owin; 7 | using Microsoft.Owin.Security.Cookies; 8 | using Microsoft.Owin.Security.Google; 9 | using Microsoft.Owin.Security.OAuth; 10 | using Owin; 11 | using XamarinWebAPI.Providers; 12 | using XamarinWebAPI.Models; 13 | 14 | namespace XamarinWebAPI 15 | { 16 | public partial class Startup 17 | { 18 | public static OAuthAuthorizationServerOptions OAuthOptions { get; private set; } 19 | 20 | public static string PublicClientId { get; private set; } 21 | 22 | // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 23 | public void ConfigureAuth(IAppBuilder app) 24 | { 25 | // Configure the db context and user manager to use a single instance per request 26 | app.CreatePerOwinContext(ApplicationDbContext.Create); 27 | app.CreatePerOwinContext(ApplicationUserManager.Create); 28 | 29 | // Enable the application to use a cookie to store information for the signed in user 30 | // and to use a cookie to temporarily store information about a user logging in with a third party login provider 31 | app.UseCookieAuthentication(new CookieAuthenticationOptions()); 32 | app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); 33 | 34 | // Configure the application for OAuth based flow 35 | PublicClientId = "self"; 36 | OAuthOptions = new OAuthAuthorizationServerOptions 37 | { 38 | TokenEndpointPath = new PathString("/Token"), 39 | Provider = new ApplicationOAuthProvider(PublicClientId), 40 | AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"), 41 | AccessTokenExpireTimeSpan = TimeSpan.FromDays(14), 42 | AllowInsecureHttp = true 43 | }; 44 | 45 | // Enable the application to use bearer tokens to authenticate users 46 | app.UseOAuthBearerTokens(OAuthOptions); 47 | 48 | // Uncomment the following lines to enable logging in with third party login providers 49 | //app.UseMicrosoftAccountAuthentication( 50 | // clientId: "", 51 | // clientSecret: ""); 52 | 53 | //app.UseTwitterAuthentication( 54 | // consumerKey: "", 55 | // consumerSecret: ""); 56 | 57 | //app.UseFacebookAuthentication( 58 | // appId: "", 59 | // appSecret: ""); 60 | 61 | //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions() 62 | //{ 63 | // ClientId = "", 64 | // ClientSecret = "" 65 | //}); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /XamarinWebAPI/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.Http; 5 | using System.Net.Http.Headers; 6 | using System.Web.Http; 7 | using Microsoft.Owin.Security.OAuth; 8 | using Newtonsoft.Json.Serialization; 9 | 10 | namespace XamarinWebAPI 11 | { 12 | public static class WebApiConfig 13 | { 14 | public static void Register(HttpConfiguration config) 15 | { 16 | // Web API configuration and services 17 | // Configure Web API to use only bearer token authentication. 18 | config.SuppressDefaultHostAuthentication(); 19 | config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType)); 20 | config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html")); 21 | 22 | 23 | // Web API routes 24 | config.MapHttpAttributeRoutes(); 25 | 26 | config.Routes.MapHttpRoute( 27 | name: "DefaultApi", 28 | routeTemplate: "api/{controller}/{id}", 29 | defaults: new { id = RouteParameter.Optional } 30 | ); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/ApiDescriptionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using System.Web; 4 | using System.Web.Http.Description; 5 | 6 | namespace XamarinWebAPI.Areas.HelpPage 7 | { 8 | public static class ApiDescriptionExtensions 9 | { 10 | /// 11 | /// Generates an URI-friendly ID for the . E.g. "Get-Values-id_name" instead of "GetValues/{id}?name={name}" 12 | /// 13 | /// The . 14 | /// The ID as a string. 15 | public static string GetFriendlyId(this ApiDescription description) 16 | { 17 | string path = description.RelativePath; 18 | string[] urlParts = path.Split('?'); 19 | string localPath = urlParts[0]; 20 | string queryKeyString = null; 21 | if (urlParts.Length > 1) 22 | { 23 | string query = urlParts[1]; 24 | string[] queryKeys = HttpUtility.ParseQueryString(query).AllKeys; 25 | queryKeyString = String.Join("_", queryKeys); 26 | } 27 | 28 | StringBuilder friendlyPath = new StringBuilder(); 29 | friendlyPath.AppendFormat("{0}-{1}", 30 | description.HttpMethod.Method, 31 | localPath.Replace("/", "-").Replace("{", String.Empty).Replace("}", String.Empty)); 32 | if (queryKeyString != null) 33 | { 34 | friendlyPath.AppendFormat("_{0}", queryKeyString.Replace('.', '-')); 35 | } 36 | return friendlyPath.ToString(); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/App_Start/HelpPageConfig.cs: -------------------------------------------------------------------------------- 1 | // Uncomment the following to provide samples for PageResult. Must also add the Microsoft.AspNet.WebApi.OData 2 | // package to your project. 3 | ////#define Handle_PageResultOfT 4 | 5 | using System; 6 | using System.Collections; 7 | using System.Collections.Generic; 8 | using System.Diagnostics; 9 | using System.Diagnostics.CodeAnalysis; 10 | using System.Linq; 11 | using System.Net.Http.Headers; 12 | using System.Reflection; 13 | using System.Web; 14 | using System.Web.Http; 15 | #if Handle_PageResultOfT 16 | using System.Web.Http.OData; 17 | #endif 18 | 19 | namespace XamarinWebAPI.Areas.HelpPage 20 | { 21 | /// 22 | /// Use this class to customize the Help Page. 23 | /// For example you can set a custom to supply the documentation 24 | /// or you can provide the samples for the requests/responses. 25 | /// 26 | public static class HelpPageConfig 27 | { 28 | [SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", 29 | MessageId = "XamarinWebAPI.Areas.HelpPage.TextSample.#ctor(System.String)", 30 | Justification = "End users may choose to merge this string with existing localized resources.")] 31 | [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", 32 | MessageId = "bsonspec", 33 | Justification = "Part of a URI.")] 34 | public static void Register(HttpConfiguration config) 35 | { 36 | //// Uncomment the following to use the documentation from XML documentation file. 37 | //config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml"))); 38 | 39 | //// Uncomment the following to use "sample string" as the sample for all actions that have string as the body parameter or return type. 40 | //// Also, the string arrays will be used for IEnumerable. The sample objects will be serialized into different media type 41 | //// formats by the available formatters. 42 | //config.SetSampleObjects(new Dictionary 43 | //{ 44 | // {typeof(string), "sample string"}, 45 | // {typeof(IEnumerable), new string[]{"sample 1", "sample 2"}} 46 | //}); 47 | 48 | // Extend the following to provide factories for types not handled automatically (those lacking parameterless 49 | // constructors) or for which you prefer to use non-default property values. Line below provides a fallback 50 | // since automatic handling will fail and GeneratePageResult handles only a single type. 51 | #if Handle_PageResultOfT 52 | config.GetHelpPageSampleGenerator().SampleObjectFactories.Add(GeneratePageResult); 53 | #endif 54 | 55 | // Extend the following to use a preset object directly as the sample for all actions that support a media 56 | // type, regardless of the body parameter or return type. The lines below avoid display of binary content. 57 | // The BsonMediaTypeFormatter (if available) is not used to serialize the TextSample object. 58 | config.SetSampleForMediaType( 59 | new TextSample("Binary JSON content. See http://bsonspec.org for details."), 60 | new MediaTypeHeaderValue("application/bson")); 61 | 62 | //// Uncomment the following to use "[0]=foo&[1]=bar" directly as the sample for all actions that support form URL encoded format 63 | //// and have IEnumerable as the body parameter or return type. 64 | //config.SetSampleForType("[0]=foo&[1]=bar", new MediaTypeHeaderValue("application/x-www-form-urlencoded"), typeof(IEnumerable)); 65 | 66 | //// Uncomment the following to use "1234" directly as the request sample for media type "text/plain" on the controller named "Values" 67 | //// and action named "Put". 68 | //config.SetSampleRequest("1234", new MediaTypeHeaderValue("text/plain"), "Values", "Put"); 69 | 70 | //// Uncomment the following to use the image on "../images/aspNetHome.png" directly as the response sample for media type "image/png" 71 | //// on the controller named "Values" and action named "Get" with parameter "id". 72 | //config.SetSampleResponse(new ImageSample("../images/aspNetHome.png"), new MediaTypeHeaderValue("image/png"), "Values", "Get", "id"); 73 | 74 | //// Uncomment the following to correct the sample request when the action expects an HttpRequestMessage with ObjectContent. 75 | //// The sample will be generated as if the controller named "Values" and action named "Get" were having string as the body parameter. 76 | //config.SetActualRequestType(typeof(string), "Values", "Get"); 77 | 78 | //// Uncomment the following to correct the sample response when the action returns an HttpResponseMessage with ObjectContent. 79 | //// The sample will be generated as if the controller named "Values" and action named "Post" were returning a string. 80 | //config.SetActualResponseType(typeof(string), "Values", "Post"); 81 | } 82 | 83 | #if Handle_PageResultOfT 84 | private static object GeneratePageResult(HelpPageSampleGenerator sampleGenerator, Type type) 85 | { 86 | if (type.IsGenericType) 87 | { 88 | Type openGenericType = type.GetGenericTypeDefinition(); 89 | if (openGenericType == typeof(PageResult<>)) 90 | { 91 | // Get the T in PageResult 92 | Type[] typeParameters = type.GetGenericArguments(); 93 | Debug.Assert(typeParameters.Length == 1); 94 | 95 | // Create an enumeration to pass as the first parameter to the PageResult constuctor 96 | Type itemsType = typeof(List<>).MakeGenericType(typeParameters); 97 | object items = sampleGenerator.GetSampleObject(itemsType); 98 | 99 | // Fill in the other information needed to invoke the PageResult constuctor 100 | Type[] parameterTypes = new Type[] { itemsType, typeof(Uri), typeof(long?), }; 101 | object[] parameters = new object[] { items, null, (long)ObjectGenerator.DefaultCollectionSize, }; 102 | 103 | // Call PageResult(IEnumerable items, Uri nextPageLink, long? count) constructor 104 | ConstructorInfo constructor = type.GetConstructor(parameterTypes); 105 | return constructor.Invoke(parameters); 106 | } 107 | } 108 | 109 | return null; 110 | } 111 | #endif 112 | } 113 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Controllers/HelpController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.Http; 3 | using System.Web.Mvc; 4 | using XamarinWebAPI.Areas.HelpPage.ModelDescriptions; 5 | using XamarinWebAPI.Areas.HelpPage.Models; 6 | 7 | namespace XamarinWebAPI.Areas.HelpPage.Controllers 8 | { 9 | /// 10 | /// The controller that will handle requests for the help page. 11 | /// 12 | public class HelpController : Controller 13 | { 14 | private const string ErrorViewName = "Error"; 15 | 16 | public HelpController() 17 | : this(GlobalConfiguration.Configuration) 18 | { 19 | } 20 | 21 | public HelpController(HttpConfiguration config) 22 | { 23 | Configuration = config; 24 | } 25 | 26 | public HttpConfiguration Configuration { get; private set; } 27 | 28 | public ActionResult Index() 29 | { 30 | ViewBag.DocumentationProvider = Configuration.Services.GetDocumentationProvider(); 31 | return View(Configuration.Services.GetApiExplorer().ApiDescriptions); 32 | } 33 | 34 | public ActionResult Api(string apiId) 35 | { 36 | if (!String.IsNullOrEmpty(apiId)) 37 | { 38 | HelpPageApiModel apiModel = Configuration.GetHelpPageApiModel(apiId); 39 | if (apiModel != null) 40 | { 41 | return View(apiModel); 42 | } 43 | } 44 | 45 | return View(ErrorViewName); 46 | } 47 | 48 | public ActionResult ResourceModel(string modelName) 49 | { 50 | if (!String.IsNullOrEmpty(modelName)) 51 | { 52 | ModelDescriptionGenerator modelDescriptionGenerator = Configuration.GetModelDescriptionGenerator(); 53 | ModelDescription modelDescription; 54 | if (modelDescriptionGenerator.GeneratedModels.TryGetValue(modelName, out modelDescription)) 55 | { 56 | return View(modelDescription); 57 | } 58 | } 59 | 60 | return View(ErrorViewName); 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/HelpPage.css: -------------------------------------------------------------------------------- 1 | .help-page h1, 2 | .help-page .h1, 3 | .help-page h2, 4 | .help-page .h2, 5 | .help-page h3, 6 | .help-page .h3, 7 | #body.help-page, 8 | .help-page-table th, 9 | .help-page-table pre, 10 | .help-page-table p { 11 | font-family: "Segoe UI Light", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif; 12 | } 13 | 14 | .help-page pre.wrapped { 15 | white-space: -moz-pre-wrap; 16 | white-space: -pre-wrap; 17 | white-space: -o-pre-wrap; 18 | white-space: pre-wrap; 19 | } 20 | 21 | .help-page .warning-message-container { 22 | margin-top: 20px; 23 | padding: 0 10px; 24 | color: #525252; 25 | background: #EFDCA9; 26 | border: 1px solid #CCCCCC; 27 | } 28 | 29 | .help-page-table { 30 | width: 100%; 31 | border-collapse: collapse; 32 | text-align: left; 33 | margin: 0px 0px 20px 0px; 34 | border-top: 1px solid #D4D4D4; 35 | } 36 | 37 | .help-page-table th { 38 | text-align: left; 39 | font-weight: bold; 40 | border-bottom: 1px solid #D4D4D4; 41 | padding: 5px 6px 5px 6px; 42 | } 43 | 44 | .help-page-table td { 45 | border-bottom: 1px solid #D4D4D4; 46 | padding: 10px 8px 10px 8px; 47 | vertical-align: top; 48 | } 49 | 50 | .help-page-table pre, 51 | .help-page-table p { 52 | margin: 0px; 53 | padding: 0px; 54 | font-family: inherit; 55 | font-size: 100%; 56 | } 57 | 58 | .help-page-table tbody tr:hover td { 59 | background-color: #F3F3F3; 60 | } 61 | 62 | .help-page a:hover { 63 | background-color: transparent; 64 | } 65 | 66 | .help-page .sample-header { 67 | border: 2px solid #D4D4D4; 68 | background: #00497E; 69 | color: #FFFFFF; 70 | padding: 8px 15px; 71 | border-bottom: none; 72 | display: inline-block; 73 | margin: 10px 0px 0px 0px; 74 | } 75 | 76 | .help-page .sample-content { 77 | display: block; 78 | border-width: 0; 79 | padding: 15px 20px; 80 | background: #FFFFFF; 81 | border: 2px solid #D4D4D4; 82 | margin: 0px 0px 10px 0px; 83 | } 84 | 85 | .help-page .api-name { 86 | width: 40%; 87 | } 88 | 89 | .help-page .api-documentation { 90 | width: 60%; 91 | } 92 | 93 | .help-page .parameter-name { 94 | width: 20%; 95 | } 96 | 97 | .help-page .parameter-documentation { 98 | width: 40%; 99 | } 100 | 101 | .help-page .parameter-type { 102 | width: 20%; 103 | } 104 | 105 | .help-page .parameter-annotations { 106 | width: 20%; 107 | } 108 | 109 | .help-page h1, 110 | .help-page .h1 { 111 | font-size: 36px; 112 | line-height: normal; 113 | } 114 | 115 | .help-page h2, 116 | .help-page .h2 { 117 | font-size: 24px; 118 | } 119 | 120 | .help-page h3, 121 | .help-page .h3 { 122 | font-size: 20px; 123 | } 124 | 125 | #body.help-page { 126 | font-size: 14px; 127 | line-height: 143%; 128 | color: #333; 129 | } 130 | 131 | .help-page a { 132 | color: #0000EE; 133 | text-decoration: none; 134 | } 135 | -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/HelpPageAreaRegistration.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Http; 2 | using System.Web.Mvc; 3 | 4 | namespace XamarinWebAPI.Areas.HelpPage 5 | { 6 | public class HelpPageAreaRegistration : AreaRegistration 7 | { 8 | public override string AreaName 9 | { 10 | get 11 | { 12 | return "HelpPage"; 13 | } 14 | } 15 | 16 | public override void RegisterArea(AreaRegistrationContext context) 17 | { 18 | context.MapRoute( 19 | "HelpPage_Default", 20 | "Help/{action}/{apiId}", 21 | new { controller = "Help", action = "Index", apiId = UrlParameter.Optional }); 22 | 23 | HelpPageConfig.Register(GlobalConfiguration.Configuration); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/ModelDescriptions/CollectionModelDescription.cs: -------------------------------------------------------------------------------- 1 | namespace XamarinWebAPI.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class CollectionModelDescription : ModelDescription 4 | { 5 | public ModelDescription ElementDescription { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/ModelDescriptions/ComplexTypeModelDescription.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | 3 | namespace XamarinWebAPI.Areas.HelpPage.ModelDescriptions 4 | { 5 | public class ComplexTypeModelDescription : ModelDescription 6 | { 7 | public ComplexTypeModelDescription() 8 | { 9 | Properties = new Collection(); 10 | } 11 | 12 | public Collection Properties { get; private set; } 13 | } 14 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/ModelDescriptions/DictionaryModelDescription.cs: -------------------------------------------------------------------------------- 1 | namespace XamarinWebAPI.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class DictionaryModelDescription : KeyValuePairModelDescription 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/ModelDescriptions/EnumTypeModelDescription.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | 4 | namespace XamarinWebAPI.Areas.HelpPage.ModelDescriptions 5 | { 6 | public class EnumTypeModelDescription : ModelDescription 7 | { 8 | public EnumTypeModelDescription() 9 | { 10 | Values = new Collection(); 11 | } 12 | 13 | public Collection Values { get; private set; } 14 | } 15 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/ModelDescriptions/EnumValueDescription.cs: -------------------------------------------------------------------------------- 1 | namespace XamarinWebAPI.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class EnumValueDescription 4 | { 5 | public string Documentation { get; set; } 6 | 7 | public string Name { get; set; } 8 | 9 | public string Value { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/ModelDescriptions/IModelDocumentationProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace XamarinWebAPI.Areas.HelpPage.ModelDescriptions 5 | { 6 | public interface IModelDocumentationProvider 7 | { 8 | string GetDocumentation(MemberInfo member); 9 | 10 | string GetDocumentation(Type type); 11 | } 12 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/ModelDescriptions/KeyValuePairModelDescription.cs: -------------------------------------------------------------------------------- 1 | namespace XamarinWebAPI.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class KeyValuePairModelDescription : ModelDescription 4 | { 5 | public ModelDescription KeyModelDescription { get; set; } 6 | 7 | public ModelDescription ValueModelDescription { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/ModelDescriptions/ModelDescription.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace XamarinWebAPI.Areas.HelpPage.ModelDescriptions 4 | { 5 | /// 6 | /// Describes a type model. 7 | /// 8 | public abstract class ModelDescription 9 | { 10 | public string Documentation { get; set; } 11 | 12 | public Type ModelType { get; set; } 13 | 14 | public string Name { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/ModelDescriptions/ModelNameAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace XamarinWebAPI.Areas.HelpPage.ModelDescriptions 4 | { 5 | /// 6 | /// Use this attribute to change the name of the generated for a type. 7 | /// 8 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum, AllowMultiple = false, Inherited = false)] 9 | public sealed class ModelNameAttribute : Attribute 10 | { 11 | public ModelNameAttribute(string name) 12 | { 13 | Name = name; 14 | } 15 | 16 | public string Name { get; private set; } 17 | } 18 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/ModelDescriptions/ModelNameHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Linq; 4 | using System.Reflection; 5 | 6 | namespace XamarinWebAPI.Areas.HelpPage.ModelDescriptions 7 | { 8 | internal static class ModelNameHelper 9 | { 10 | // Modify this to provide custom model name mapping. 11 | public static string GetModelName(Type type) 12 | { 13 | ModelNameAttribute modelNameAttribute = type.GetCustomAttribute(); 14 | if (modelNameAttribute != null && !String.IsNullOrEmpty(modelNameAttribute.Name)) 15 | { 16 | return modelNameAttribute.Name; 17 | } 18 | 19 | string modelName = type.Name; 20 | if (type.IsGenericType) 21 | { 22 | // Format the generic type name to something like: GenericOfAgurment1AndArgument2 23 | Type genericType = type.GetGenericTypeDefinition(); 24 | Type[] genericArguments = type.GetGenericArguments(); 25 | string genericTypeName = genericType.Name; 26 | 27 | // Trim the generic parameter counts from the name 28 | genericTypeName = genericTypeName.Substring(0, genericTypeName.IndexOf('`')); 29 | string[] argumentTypeNames = genericArguments.Select(t => GetModelName(t)).ToArray(); 30 | modelName = String.Format(CultureInfo.InvariantCulture, "{0}Of{1}", genericTypeName, String.Join("And", argumentTypeNames)); 31 | } 32 | 33 | return modelName; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/ModelDescriptions/ParameterAnnotation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace XamarinWebAPI.Areas.HelpPage.ModelDescriptions 4 | { 5 | public class ParameterAnnotation 6 | { 7 | public Attribute AnnotationAttribute { get; set; } 8 | 9 | public string Documentation { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/ModelDescriptions/ParameterDescription.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | 4 | namespace XamarinWebAPI.Areas.HelpPage.ModelDescriptions 5 | { 6 | public class ParameterDescription 7 | { 8 | public ParameterDescription() 9 | { 10 | Annotations = new Collection(); 11 | } 12 | 13 | public Collection Annotations { get; private set; } 14 | 15 | public string Documentation { get; set; } 16 | 17 | public string Name { get; set; } 18 | 19 | public ModelDescription TypeDescription { get; set; } 20 | } 21 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/ModelDescriptions/SimpleTypeModelDescription.cs: -------------------------------------------------------------------------------- 1 | namespace XamarinWebAPI.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class SimpleTypeModelDescription : ModelDescription 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Models/HelpPageApiModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | using System.Net.Http.Headers; 4 | using System.Web.Http.Description; 5 | using XamarinWebAPI.Areas.HelpPage.ModelDescriptions; 6 | 7 | namespace XamarinWebAPI.Areas.HelpPage.Models 8 | { 9 | /// 10 | /// The model that represents an API displayed on the help page. 11 | /// 12 | public class HelpPageApiModel 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public HelpPageApiModel() 18 | { 19 | UriParameters = new Collection(); 20 | SampleRequests = new Dictionary(); 21 | SampleResponses = new Dictionary(); 22 | ErrorMessages = new Collection(); 23 | } 24 | 25 | /// 26 | /// Gets or sets the that describes the API. 27 | /// 28 | public ApiDescription ApiDescription { get; set; } 29 | 30 | /// 31 | /// Gets or sets the collection that describes the URI parameters for the API. 32 | /// 33 | public Collection UriParameters { get; private set; } 34 | 35 | /// 36 | /// Gets or sets the documentation for the request. 37 | /// 38 | public string RequestDocumentation { get; set; } 39 | 40 | /// 41 | /// Gets or sets the that describes the request body. 42 | /// 43 | public ModelDescription RequestModelDescription { get; set; } 44 | 45 | /// 46 | /// Gets the request body parameter descriptions. 47 | /// 48 | public IList RequestBodyParameters 49 | { 50 | get 51 | { 52 | return GetParameterDescriptions(RequestModelDescription); 53 | } 54 | } 55 | 56 | /// 57 | /// Gets or sets the that describes the resource. 58 | /// 59 | public ModelDescription ResourceDescription { get; set; } 60 | 61 | /// 62 | /// Gets the resource property descriptions. 63 | /// 64 | public IList ResourceProperties 65 | { 66 | get 67 | { 68 | return GetParameterDescriptions(ResourceDescription); 69 | } 70 | } 71 | 72 | /// 73 | /// Gets the sample requests associated with the API. 74 | /// 75 | public IDictionary SampleRequests { get; private set; } 76 | 77 | /// 78 | /// Gets the sample responses associated with the API. 79 | /// 80 | public IDictionary SampleResponses { get; private set; } 81 | 82 | /// 83 | /// Gets the error messages associated with this model. 84 | /// 85 | public Collection ErrorMessages { get; private set; } 86 | 87 | private static IList GetParameterDescriptions(ModelDescription modelDescription) 88 | { 89 | ComplexTypeModelDescription complexTypeModelDescription = modelDescription as ComplexTypeModelDescription; 90 | if (complexTypeModelDescription != null) 91 | { 92 | return complexTypeModelDescription.Properties; 93 | } 94 | 95 | CollectionModelDescription collectionModelDescription = modelDescription as CollectionModelDescription; 96 | if (collectionModelDescription != null) 97 | { 98 | complexTypeModelDescription = collectionModelDescription.ElementDescription as ComplexTypeModelDescription; 99 | if (complexTypeModelDescription != null) 100 | { 101 | return complexTypeModelDescription.Properties; 102 | } 103 | } 104 | 105 | return null; 106 | } 107 | } 108 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/SampleGeneration/HelpPageSampleKey.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Net.Http.Headers; 5 | 6 | namespace XamarinWebAPI.Areas.HelpPage 7 | { 8 | /// 9 | /// This is used to identify the place where the sample should be applied. 10 | /// 11 | public class HelpPageSampleKey 12 | { 13 | /// 14 | /// Creates a new based on media type. 15 | /// 16 | /// The media type. 17 | public HelpPageSampleKey(MediaTypeHeaderValue mediaType) 18 | { 19 | if (mediaType == null) 20 | { 21 | throw new ArgumentNullException("mediaType"); 22 | } 23 | 24 | ActionName = String.Empty; 25 | ControllerName = String.Empty; 26 | MediaType = mediaType; 27 | ParameterNames = new HashSet(StringComparer.OrdinalIgnoreCase); 28 | } 29 | 30 | /// 31 | /// Creates a new based on media type and CLR type. 32 | /// 33 | /// The media type. 34 | /// The CLR type. 35 | public HelpPageSampleKey(MediaTypeHeaderValue mediaType, Type type) 36 | : this(mediaType) 37 | { 38 | if (type == null) 39 | { 40 | throw new ArgumentNullException("type"); 41 | } 42 | 43 | ParameterType = type; 44 | } 45 | 46 | /// 47 | /// Creates a new based on , controller name, action name and parameter names. 48 | /// 49 | /// The . 50 | /// Name of the controller. 51 | /// Name of the action. 52 | /// The parameter names. 53 | public HelpPageSampleKey(SampleDirection sampleDirection, string controllerName, string actionName, IEnumerable parameterNames) 54 | { 55 | if (!Enum.IsDefined(typeof(SampleDirection), sampleDirection)) 56 | { 57 | throw new InvalidEnumArgumentException("sampleDirection", (int)sampleDirection, typeof(SampleDirection)); 58 | } 59 | if (controllerName == null) 60 | { 61 | throw new ArgumentNullException("controllerName"); 62 | } 63 | if (actionName == null) 64 | { 65 | throw new ArgumentNullException("actionName"); 66 | } 67 | if (parameterNames == null) 68 | { 69 | throw new ArgumentNullException("parameterNames"); 70 | } 71 | 72 | ControllerName = controllerName; 73 | ActionName = actionName; 74 | ParameterNames = new HashSet(parameterNames, StringComparer.OrdinalIgnoreCase); 75 | SampleDirection = sampleDirection; 76 | } 77 | 78 | /// 79 | /// Creates a new based on media type, , controller name, action name and parameter names. 80 | /// 81 | /// The media type. 82 | /// The . 83 | /// Name of the controller. 84 | /// Name of the action. 85 | /// The parameter names. 86 | public HelpPageSampleKey(MediaTypeHeaderValue mediaType, SampleDirection sampleDirection, string controllerName, string actionName, IEnumerable parameterNames) 87 | : this(sampleDirection, controllerName, actionName, parameterNames) 88 | { 89 | if (mediaType == null) 90 | { 91 | throw new ArgumentNullException("mediaType"); 92 | } 93 | 94 | MediaType = mediaType; 95 | } 96 | 97 | /// 98 | /// Gets the name of the controller. 99 | /// 100 | /// 101 | /// The name of the controller. 102 | /// 103 | public string ControllerName { get; private set; } 104 | 105 | /// 106 | /// Gets the name of the action. 107 | /// 108 | /// 109 | /// The name of the action. 110 | /// 111 | public string ActionName { get; private set; } 112 | 113 | /// 114 | /// Gets the media type. 115 | /// 116 | /// 117 | /// The media type. 118 | /// 119 | public MediaTypeHeaderValue MediaType { get; private set; } 120 | 121 | /// 122 | /// Gets the parameter names. 123 | /// 124 | public HashSet ParameterNames { get; private set; } 125 | 126 | public Type ParameterType { get; private set; } 127 | 128 | /// 129 | /// Gets the . 130 | /// 131 | public SampleDirection? SampleDirection { get; private set; } 132 | 133 | public override bool Equals(object obj) 134 | { 135 | HelpPageSampleKey otherKey = obj as HelpPageSampleKey; 136 | if (otherKey == null) 137 | { 138 | return false; 139 | } 140 | 141 | return String.Equals(ControllerName, otherKey.ControllerName, StringComparison.OrdinalIgnoreCase) && 142 | String.Equals(ActionName, otherKey.ActionName, StringComparison.OrdinalIgnoreCase) && 143 | (MediaType == otherKey.MediaType || (MediaType != null && MediaType.Equals(otherKey.MediaType))) && 144 | ParameterType == otherKey.ParameterType && 145 | SampleDirection == otherKey.SampleDirection && 146 | ParameterNames.SetEquals(otherKey.ParameterNames); 147 | } 148 | 149 | public override int GetHashCode() 150 | { 151 | int hashCode = ControllerName.ToUpperInvariant().GetHashCode() ^ ActionName.ToUpperInvariant().GetHashCode(); 152 | if (MediaType != null) 153 | { 154 | hashCode ^= MediaType.GetHashCode(); 155 | } 156 | if (SampleDirection != null) 157 | { 158 | hashCode ^= SampleDirection.GetHashCode(); 159 | } 160 | if (ParameterType != null) 161 | { 162 | hashCode ^= ParameterType.GetHashCode(); 163 | } 164 | foreach (string parameterName in ParameterNames) 165 | { 166 | hashCode ^= parameterName.ToUpperInvariant().GetHashCode(); 167 | } 168 | 169 | return hashCode; 170 | } 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/SampleGeneration/ImageSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace XamarinWebAPI.Areas.HelpPage 4 | { 5 | /// 6 | /// This represents an image sample on the help page. There's a display template named ImageSample associated with this class. 7 | /// 8 | public class ImageSample 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | /// The URL of an image. 14 | public ImageSample(string src) 15 | { 16 | if (src == null) 17 | { 18 | throw new ArgumentNullException("src"); 19 | } 20 | Src = src; 21 | } 22 | 23 | public string Src { get; private set; } 24 | 25 | public override bool Equals(object obj) 26 | { 27 | ImageSample other = obj as ImageSample; 28 | return other != null && Src == other.Src; 29 | } 30 | 31 | public override int GetHashCode() 32 | { 33 | return Src.GetHashCode(); 34 | } 35 | 36 | public override string ToString() 37 | { 38 | return Src; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/SampleGeneration/InvalidSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace XamarinWebAPI.Areas.HelpPage 4 | { 5 | /// 6 | /// This represents an invalid sample on the help page. There's a display template named InvalidSample associated with this class. 7 | /// 8 | public class InvalidSample 9 | { 10 | public InvalidSample(string errorMessage) 11 | { 12 | if (errorMessage == null) 13 | { 14 | throw new ArgumentNullException("errorMessage"); 15 | } 16 | ErrorMessage = errorMessage; 17 | } 18 | 19 | public string ErrorMessage { get; private set; } 20 | 21 | public override bool Equals(object obj) 22 | { 23 | InvalidSample other = obj as InvalidSample; 24 | return other != null && ErrorMessage == other.ErrorMessage; 25 | } 26 | 27 | public override int GetHashCode() 28 | { 29 | return ErrorMessage.GetHashCode(); 30 | } 31 | 32 | public override string ToString() 33 | { 34 | return ErrorMessage; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/SampleGeneration/SampleDirection.cs: -------------------------------------------------------------------------------- 1 | namespace XamarinWebAPI.Areas.HelpPage 2 | { 3 | /// 4 | /// Indicates whether the sample is used for request or response 5 | /// 6 | public enum SampleDirection 7 | { 8 | Request = 0, 9 | Response 10 | } 11 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/SampleGeneration/TextSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace XamarinWebAPI.Areas.HelpPage 4 | { 5 | /// 6 | /// This represents a preformatted text sample on the help page. There's a display template named TextSample associated with this class. 7 | /// 8 | public class TextSample 9 | { 10 | public TextSample(string text) 11 | { 12 | if (text == null) 13 | { 14 | throw new ArgumentNullException("text"); 15 | } 16 | Text = text; 17 | } 18 | 19 | public string Text { get; private set; } 20 | 21 | public override bool Equals(object obj) 22 | { 23 | TextSample other = obj as TextSample; 24 | return other != null && Text == other.Text; 25 | } 26 | 27 | public override int GetHashCode() 28 | { 29 | return Text.GetHashCode(); 30 | } 31 | 32 | public override string ToString() 33 | { 34 | return Text; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Help/Api.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using XamarinWebAPI.Areas.HelpPage.Models 3 | @model HelpPageApiModel 4 | 5 | @{ 6 | var description = Model.ApiDescription; 7 | ViewBag.Title = description.HttpMethod.Method + " " + description.RelativePath; 8 | } 9 | 10 | 11 |
12 | 19 |
20 | @Html.DisplayForModel() 21 |
22 |
23 | -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/ApiGroup.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using System.Web.Http.Controllers 3 | @using System.Web.Http.Description 4 | @using XamarinWebAPI.Areas.HelpPage 5 | @using XamarinWebAPI.Areas.HelpPage.Models 6 | @model IGrouping 7 | 8 | @{ 9 | var controllerDocumentation = ViewBag.DocumentationProvider != null ? 10 | ViewBag.DocumentationProvider.GetDocumentation(Model.Key) : 11 | null; 12 | } 13 | 14 |

@Model.Key.ControllerName

15 | @if (!String.IsNullOrEmpty(controllerDocumentation)) 16 | { 17 |

@controllerDocumentation

18 | } 19 | 20 | 21 | 22 | 23 | 24 | @foreach (var api in Model) 25 | { 26 | 27 | 28 | 38 | 39 | } 40 | 41 |
APIDescription
@api.HttpMethod.Method @api.RelativePath 29 | @if (api.Documentation != null) 30 | { 31 |

@api.Documentation

32 | } 33 | else 34 | { 35 |

No documentation available.

36 | } 37 |
-------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/CollectionModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using XamarinWebAPI.Areas.HelpPage.ModelDescriptions 2 | @model CollectionModelDescription 3 | @if (Model.ElementDescription is ComplexTypeModelDescription) 4 | { 5 | @Html.DisplayFor(m => m.ElementDescription) 6 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/ComplexTypeModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using XamarinWebAPI.Areas.HelpPage.ModelDescriptions 2 | @model ComplexTypeModelDescription 3 | @Html.DisplayFor(m => m.Properties, "Parameters") -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/DictionaryModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using XamarinWebAPI.Areas.HelpPage.ModelDescriptions 2 | @model DictionaryModelDescription 3 | Dictionary of @Html.DisplayFor(m => Model.KeyModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.KeyModelDescription }) [key] 4 | and @Html.DisplayFor(m => Model.ValueModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.ValueModelDescription }) [value] -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/EnumTypeModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using XamarinWebAPI.Areas.HelpPage.ModelDescriptions 2 | @model EnumTypeModelDescription 3 | 4 |

Possible enumeration values:

5 | 6 | 7 | 8 | 9 | 10 | 11 | @foreach (EnumValueDescription value in Model.Values) 12 | { 13 | 14 | 15 | 18 | 21 | 22 | } 23 | 24 |
NameValueDescription
@value.Name 16 |

@value.Value

17 |
19 |

@value.Documentation

20 |
-------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/HelpPageApiModel.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using System.Web.Http.Description 3 | @using XamarinWebAPI.Areas.HelpPage.Models 4 | @using XamarinWebAPI.Areas.HelpPage.ModelDescriptions 5 | @model HelpPageApiModel 6 | 7 | @{ 8 | ApiDescription description = Model.ApiDescription; 9 | } 10 |

@description.HttpMethod.Method @description.RelativePath

11 |
12 |

@description.Documentation

13 | 14 |

Request Information

15 | 16 |

URI Parameters

17 | @Html.DisplayFor(m => m.UriParameters, "Parameters") 18 | 19 |

Body Parameters

20 | 21 |

@Model.RequestDocumentation

22 | 23 | @if (Model.RequestModelDescription != null) 24 | { 25 | @Html.DisplayFor(m => m.RequestModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.RequestModelDescription }) 26 | if (Model.RequestBodyParameters != null) 27 | { 28 | @Html.DisplayFor(m => m.RequestBodyParameters, "Parameters") 29 | } 30 | } 31 | else 32 | { 33 |

None.

34 | } 35 | 36 | @if (Model.SampleRequests.Count > 0) 37 | { 38 |

Request Formats

39 | @Html.DisplayFor(m => m.SampleRequests, "Samples") 40 | } 41 | 42 |

Response Information

43 | 44 |

Resource Description

45 | 46 |

@description.ResponseDescription.Documentation

47 | 48 | @if (Model.ResourceDescription != null) 49 | { 50 | @Html.DisplayFor(m => m.ResourceDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.ResourceDescription }) 51 | if (Model.ResourceProperties != null) 52 | { 53 | @Html.DisplayFor(m => m.ResourceProperties, "Parameters") 54 | } 55 | } 56 | else 57 | { 58 |

None.

59 | } 60 | 61 | @if (Model.SampleResponses.Count > 0) 62 | { 63 |

Response Formats

64 | @Html.DisplayFor(m => m.SampleResponses, "Samples") 65 | } 66 | 67 |
-------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/ImageSample.cshtml: -------------------------------------------------------------------------------- 1 | @using XamarinWebAPI.Areas.HelpPage 2 | @model ImageSample 3 | 4 | -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/InvalidSample.cshtml: -------------------------------------------------------------------------------- 1 | @using XamarinWebAPI.Areas.HelpPage 2 | @model InvalidSample 3 | 4 | @if (HttpContext.Current.IsDebuggingEnabled) 5 | { 6 |
7 |

@Model.ErrorMessage

8 |
9 | } 10 | else 11 | { 12 |

Sample not available.

13 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/KeyValuePairModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using XamarinWebAPI.Areas.HelpPage.ModelDescriptions 2 | @model KeyValuePairModelDescription 3 | Pair of @Html.DisplayFor(m => Model.KeyModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.KeyModelDescription }) [key] 4 | and @Html.DisplayFor(m => Model.ValueModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.ValueModelDescription }) [value] -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/ModelDescriptionLink.cshtml: -------------------------------------------------------------------------------- 1 | @using XamarinWebAPI.Areas.HelpPage.ModelDescriptions 2 | @model Type 3 | @{ 4 | ModelDescription modelDescription = ViewBag.modelDescription; 5 | if (modelDescription is ComplexTypeModelDescription || modelDescription is EnumTypeModelDescription) 6 | { 7 | if (Model == typeof(Object)) 8 | { 9 | @:Object 10 | } 11 | else 12 | { 13 | @Html.ActionLink(modelDescription.Name, "ResourceModel", "Help", new { modelName = modelDescription.Name }, null) 14 | } 15 | } 16 | else if (modelDescription is CollectionModelDescription) 17 | { 18 | var collectionDescription = modelDescription as CollectionModelDescription; 19 | var elementDescription = collectionDescription.ElementDescription; 20 | @:Collection of @Html.DisplayFor(m => elementDescription.ModelType, "ModelDescriptionLink", new { modelDescription = elementDescription }) 21 | } 22 | else 23 | { 24 | @Html.DisplayFor(m => modelDescription) 25 | } 26 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/Parameters.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Collections.Generic 2 | @using System.Collections.ObjectModel 3 | @using System.Web.Http.Description 4 | @using System.Threading 5 | @using XamarinWebAPI.Areas.HelpPage.ModelDescriptions 6 | @model IList 7 | 8 | @if (Model.Count > 0) 9 | { 10 | 11 | 12 | 13 | 14 | 15 | @foreach (ParameterDescription parameter in Model) 16 | { 17 | ModelDescription modelDescription = parameter.TypeDescription; 18 | 19 | 20 | 23 | 26 | 39 | 40 | } 41 | 42 |
NameDescriptionTypeAdditional information
@parameter.Name 21 |

@parameter.Documentation

22 |
24 | @Html.DisplayFor(m => modelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = modelDescription }) 25 | 27 | @if (parameter.Annotations.Count > 0) 28 | { 29 | foreach (var annotation in parameter.Annotations) 30 | { 31 |

@annotation.Documentation

32 | } 33 | } 34 | else 35 | { 36 |

None.

37 | } 38 |
43 | } 44 | else 45 | { 46 |

None.

47 | } 48 | 49 | -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/Samples.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Net.Http.Headers 2 | @model Dictionary 3 | 4 | @{ 5 | // Group the samples into a single tab if they are the same. 6 | Dictionary samples = Model.GroupBy(pair => pair.Value).ToDictionary( 7 | pair => String.Join(", ", pair.Select(m => m.Key.ToString()).ToArray()), 8 | pair => pair.Key); 9 | var mediaTypes = samples.Keys; 10 | } 11 |
12 | @foreach (var mediaType in mediaTypes) 13 | { 14 |

@mediaType

15 |
16 | Sample: 17 | @{ 18 | var sample = samples[mediaType]; 19 | if (sample == null) 20 | { 21 |

Sample not available.

22 | } 23 | else 24 | { 25 | @Html.DisplayFor(s => sample); 26 | } 27 | } 28 |
29 | } 30 |
-------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/SimpleTypeModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using XamarinWebAPI.Areas.HelpPage.ModelDescriptions 2 | @model SimpleTypeModelDescription 3 | @Model.Documentation -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/TextSample.cshtml: -------------------------------------------------------------------------------- 1 | @using XamarinWebAPI.Areas.HelpPage 2 | @model TextSample 3 | 4 |
5 | @Model.Text
6 | 
-------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Help/Index.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using System.Web.Http.Controllers 3 | @using System.Web.Http.Description 4 | @using System.Collections.ObjectModel 5 | @using XamarinWebAPI.Areas.HelpPage.Models 6 | @model Collection 7 | 8 | @{ 9 | ViewBag.Title = "ASP.NET Web API Help Page"; 10 | 11 | // Group APIs by controller 12 | ILookup apiGroups = Model.ToLookup(api => api.ActionDescriptor.ControllerDescriptor); 13 | } 14 | 15 | 16 |
17 |
18 |
19 |

@ViewBag.Title

20 |
21 |
22 |
23 |
24 | 32 |
33 | @foreach (var group in apiGroups) 34 | { 35 | @Html.DisplayFor(m => group, "ApiGroup") 36 | } 37 |
38 |
39 | -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Help/ResourceModel.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using XamarinWebAPI.Areas.HelpPage.ModelDescriptions 3 | @model ModelDescription 4 | 5 | 6 |
7 | 14 |

@Model.Name

15 |

@Model.Documentation

16 |
17 | @Html.DisplayFor(m => Model) 18 |
19 |
20 | -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | @ViewBag.Title 7 | @RenderSection("scripts", required: false) 8 | 9 | 10 | @RenderBody() 11 | 12 | -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /XamarinWebAPI/Areas/HelpPage/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | // Change the Layout path below to blend the look and feel of the help page with your existing web pages 3 | Layout = "~/Views/Shared/_Layout.cshtml"; 4 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Content/Site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | /* Set padding to keep content from hitting the edges */ 7 | .body-content { 8 | padding-left: 15px; 9 | padding-right: 15px; 10 | } 11 | 12 | /* Set width on the form input elements since they're 100% wide by default */ 13 | input, 14 | select, 15 | textarea { 16 | max-width: 280px; 17 | } 18 | -------------------------------------------------------------------------------- /XamarinWebAPI/Controllers/ApiPersonController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Data; 4 | using System.Data.Entity; 5 | using System.Data.Entity.Infrastructure; 6 | using System.Linq; 7 | using System.Net; 8 | using System.Net.Http; 9 | using System.Web.Http; 10 | using System.Web.Http.Description; 11 | using XamarinWebAPI.Models; 12 | 13 | namespace XamarinWebAPI.Controllers 14 | { 15 | public class ApiPersonController : ApiController 16 | { 17 | private ApplicationDbContext db = new ApplicationDbContext(); 18 | 19 | // GET: api/ApiPerson 20 | public IQueryable GetPeople() 21 | { 22 | return db.People; 23 | } 24 | 25 | // GET: api/ApiPerson/5 26 | [ResponseType(typeof(Person))] 27 | public IHttpActionResult GetPerson(int id) 28 | { 29 | Person person = db.People.Find(id); 30 | if (person == null) 31 | { 32 | return NotFound(); 33 | } 34 | 35 | return Ok(person); 36 | } 37 | 38 | // PUT: api/ApiPerson/5 39 | [ResponseType(typeof(void))] 40 | public IHttpActionResult PutPerson(int id, Person person) 41 | { 42 | if (!ModelState.IsValid) 43 | { 44 | return BadRequest(ModelState); 45 | } 46 | 47 | if (id != person.Id) 48 | { 49 | return BadRequest(); 50 | } 51 | 52 | db.Entry(person).State = EntityState.Modified; 53 | 54 | try 55 | { 56 | db.SaveChanges(); 57 | } 58 | catch (DbUpdateConcurrencyException) 59 | { 60 | if (!PersonExists(id)) 61 | { 62 | return NotFound(); 63 | } 64 | else 65 | { 66 | throw; 67 | } 68 | } 69 | 70 | return StatusCode(HttpStatusCode.NoContent); 71 | } 72 | 73 | // POST: api/ApiPerson 74 | [ResponseType(typeof(Person))] 75 | public IHttpActionResult PostPerson(Person person) 76 | { 77 | if (!ModelState.IsValid) 78 | { 79 | return BadRequest(ModelState); 80 | } 81 | 82 | db.People.Add(person); 83 | db.SaveChanges(); 84 | 85 | return CreatedAtRoute("DefaultApi", new { id = person.Id }, person); 86 | } 87 | 88 | // DELETE: api/ApiPerson/5 89 | [ResponseType(typeof(Person))] 90 | public IHttpActionResult DeletePerson(int id) 91 | { 92 | Person person = db.People.Find(id); 93 | if (person == null) 94 | { 95 | return NotFound(); 96 | } 97 | 98 | db.People.Remove(person); 99 | db.SaveChanges(); 100 | 101 | return Ok(person); 102 | } 103 | 104 | protected override void Dispose(bool disposing) 105 | { 106 | if (disposing) 107 | { 108 | db.Dispose(); 109 | } 110 | base.Dispose(disposing); 111 | } 112 | 113 | private bool PersonExists(int id) 114 | { 115 | return db.People.Count(e => e.Id == id) > 0; 116 | } 117 | } 118 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | 7 | namespace XamarinWebAPI.Controllers 8 | { 9 | public class HomeController : Controller 10 | { 11 | public ActionResult Index() 12 | { 13 | ViewBag.Title = "Home Page"; 14 | 15 | return View(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /XamarinWebAPI/Controllers/PersonController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Data; 4 | using System.Data.Entity; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Net; 8 | using System.Web; 9 | using System.Web.Mvc; 10 | using XamarinWebAPI.Models; 11 | 12 | namespace XamarinWebAPI.Controllers 13 | { 14 | public class PersonController : Controller 15 | { 16 | private ApplicationDbContext db = new ApplicationDbContext(); 17 | 18 | // GET: Person 19 | public async Task Index() 20 | { 21 | return View(await db.People.ToListAsync()); 22 | } 23 | 24 | // GET: Person/Details/5 25 | public async Task Details(int? id) 26 | { 27 | if (id == null) 28 | { 29 | return new HttpStatusCodeResult(HttpStatusCode.BadRequest); 30 | } 31 | Person person = await db.People.FindAsync(id); 32 | if (person == null) 33 | { 34 | return HttpNotFound(); 35 | } 36 | return View(person); 37 | } 38 | 39 | // GET: Person/Create 40 | public ActionResult Create() 41 | { 42 | return View(); 43 | } 44 | 45 | // POST: Person/Create 46 | // To protect from overposting attacks, please enable the specific properties you want to bind to, for 47 | // more details see http://go.microsoft.com/fwlink/?LinkId=317598. 48 | [HttpPost] 49 | [ValidateAntiForgeryToken] 50 | public async Task Create([Bind(Include = "Id,Name,Age")] Person person) 51 | { 52 | if (ModelState.IsValid) 53 | { 54 | db.People.Add(person); 55 | await db.SaveChangesAsync(); 56 | return RedirectToAction("Index"); 57 | } 58 | 59 | return View(person); 60 | } 61 | 62 | // GET: Person/Edit/5 63 | public async Task Edit(int? id) 64 | { 65 | if (id == null) 66 | { 67 | return new HttpStatusCodeResult(HttpStatusCode.BadRequest); 68 | } 69 | Person person = await db.People.FindAsync(id); 70 | if (person == null) 71 | { 72 | return HttpNotFound(); 73 | } 74 | return View(person); 75 | } 76 | 77 | // POST: Person/Edit/5 78 | // To protect from overposting attacks, please enable the specific properties you want to bind to, for 79 | // more details see http://go.microsoft.com/fwlink/?LinkId=317598. 80 | [HttpPost] 81 | [ValidateAntiForgeryToken] 82 | public async Task Edit([Bind(Include = "Id,Name,Age")] Person person) 83 | { 84 | if (ModelState.IsValid) 85 | { 86 | db.Entry(person).State = EntityState.Modified; 87 | await db.SaveChangesAsync(); 88 | return RedirectToAction("Index"); 89 | } 90 | return View(person); 91 | } 92 | 93 | // GET: Person/Delete/5 94 | public async Task Delete(int? id) 95 | { 96 | if (id == null) 97 | { 98 | return new HttpStatusCodeResult(HttpStatusCode.BadRequest); 99 | } 100 | Person person = await db.People.FindAsync(id); 101 | if (person == null) 102 | { 103 | return HttpNotFound(); 104 | } 105 | return View(person); 106 | } 107 | 108 | // POST: Person/Delete/5 109 | [HttpPost, ActionName("Delete")] 110 | [ValidateAntiForgeryToken] 111 | public async Task DeleteConfirmed(int id) 112 | { 113 | Person person = await db.People.FindAsync(id); 114 | db.People.Remove(person); 115 | await db.SaveChangesAsync(); 116 | return RedirectToAction("Index"); 117 | } 118 | 119 | protected override void Dispose(bool disposing) 120 | { 121 | if (disposing) 122 | { 123 | db.Dispose(); 124 | } 125 | base.Dispose(disposing); 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /XamarinWebAPI/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Net.Http; 6 | using System.Web.Http; 7 | 8 | namespace XamarinWebAPI.Controllers 9 | { 10 | [Authorize] 11 | public class ValuesController : ApiController 12 | { 13 | // GET api/values 14 | public IEnumerable Get() 15 | { 16 | return new string[] { "value1", "value2" }; 17 | } 18 | 19 | // GET api/values/5 20 | public string Get(int id) 21 | { 22 | return "value"; 23 | } 24 | 25 | // POST api/values 26 | public void Post([FromBody]string value) 27 | { 28 | } 29 | 30 | // PUT api/values/5 31 | public void Put(int id, [FromBody]string value) 32 | { 33 | } 34 | 35 | // DELETE api/values/5 36 | public void Delete(int id) 37 | { 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /XamarinWebAPI/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="XamarinWebAPI.WebApiApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /XamarinWebAPI/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Http; 6 | using System.Web.Mvc; 7 | using System.Web.Optimization; 8 | using System.Web.Routing; 9 | 10 | namespace XamarinWebAPI 11 | { 12 | public class WebApiApplication : System.Web.HttpApplication 13 | { 14 | protected void Application_Start() 15 | { 16 | AreaRegistration.RegisterAllAreas(); 17 | GlobalConfiguration.Configure(WebApiConfig.Register); 18 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 19 | RouteConfig.RegisterRoutes(RouteTable.Routes); 20 | BundleConfig.RegisterBundles(BundleTable.Bundles); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /XamarinWebAPI/Models/AccountBindingModels.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.DataAnnotations; 3 | using Newtonsoft.Json; 4 | 5 | namespace XamarinWebAPI.Models 6 | { 7 | // Models used as parameters to AccountController actions. 8 | 9 | public class AddExternalLoginBindingModel 10 | { 11 | [Required] 12 | [Display(Name = "External access token")] 13 | public string ExternalAccessToken { get; set; } 14 | } 15 | 16 | public class ChangePasswordBindingModel 17 | { 18 | [Required] 19 | [DataType(DataType.Password)] 20 | [Display(Name = "Current password")] 21 | public string OldPassword { get; set; } 22 | 23 | [Required] 24 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] 25 | [DataType(DataType.Password)] 26 | [Display(Name = "New password")] 27 | public string NewPassword { get; set; } 28 | 29 | [DataType(DataType.Password)] 30 | [Display(Name = "Confirm new password")] 31 | [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] 32 | public string ConfirmPassword { get; set; } 33 | } 34 | 35 | public class RegisterBindingModel 36 | { 37 | [Required] 38 | [Display(Name = "Email")] 39 | public string Email { get; set; } 40 | 41 | [Required] 42 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] 43 | [DataType(DataType.Password)] 44 | [Display(Name = "Password")] 45 | public string Password { get; set; } 46 | 47 | [DataType(DataType.Password)] 48 | [Display(Name = "Confirm password")] 49 | [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] 50 | public string ConfirmPassword { get; set; } 51 | } 52 | 53 | public class RegisterExternalBindingModel 54 | { 55 | [Required] 56 | [Display(Name = "Email")] 57 | public string Email { get; set; } 58 | } 59 | 60 | public class RemoveLoginBindingModel 61 | { 62 | [Required] 63 | [Display(Name = "Login provider")] 64 | public string LoginProvider { get; set; } 65 | 66 | [Required] 67 | [Display(Name = "Provider key")] 68 | public string ProviderKey { get; set; } 69 | } 70 | 71 | public class SetPasswordBindingModel 72 | { 73 | [Required] 74 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] 75 | [DataType(DataType.Password)] 76 | [Display(Name = "New password")] 77 | public string NewPassword { get; set; } 78 | 79 | [DataType(DataType.Password)] 80 | [Display(Name = "Confirm new password")] 81 | [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] 82 | public string ConfirmPassword { get; set; } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /XamarinWebAPI/Models/AccountViewModels.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace XamarinWebAPI.Models 5 | { 6 | // Models returned by AccountController actions. 7 | 8 | public class ExternalLoginViewModel 9 | { 10 | public string Name { get; set; } 11 | 12 | public string Url { get; set; } 13 | 14 | public string State { get; set; } 15 | } 16 | 17 | public class ManageInfoViewModel 18 | { 19 | public string LocalLoginProvider { get; set; } 20 | 21 | public string Email { get; set; } 22 | 23 | public IEnumerable Logins { get; set; } 24 | 25 | public IEnumerable ExternalLoginProviders { get; set; } 26 | } 27 | 28 | public class UserInfoViewModel 29 | { 30 | public string Email { get; set; } 31 | 32 | public bool HasRegistered { get; set; } 33 | 34 | public string LoginProvider { get; set; } 35 | } 36 | 37 | public class UserLoginInfoViewModel 38 | { 39 | public string LoginProvider { get; set; } 40 | 41 | public string ProviderKey { get; set; } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /XamarinWebAPI/Models/IdentityModels.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Claims; 2 | using System.Threading.Tasks; 3 | using Microsoft.AspNet.Identity; 4 | using Microsoft.AspNet.Identity.EntityFramework; 5 | using Microsoft.AspNet.Identity.Owin; 6 | 7 | namespace XamarinWebAPI.Models 8 | { 9 | // You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more. 10 | public class ApplicationUser : IdentityUser 11 | { 12 | public async Task GenerateUserIdentityAsync(UserManager manager, string authenticationType) 13 | { 14 | // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType 15 | var userIdentity = await manager.CreateIdentityAsync(this, authenticationType); 16 | // Add custom user claims here 17 | return userIdentity; 18 | } 19 | } 20 | 21 | public class ApplicationDbContext : IdentityDbContext 22 | { 23 | public ApplicationDbContext() 24 | : base("DefaultConnection", throwIfV1Schema: false) 25 | { 26 | } 27 | 28 | public static ApplicationDbContext Create() 29 | { 30 | return new ApplicationDbContext(); 31 | } 32 | 33 | public System.Data.Entity.DbSet People { get; set; } 34 | } 35 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Models/Person.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace XamarinWebAPI.Models 8 | { 9 | public class Person 10 | { 11 | public int Id { get; set; } 12 | 13 | public string Name { get; set; } 14 | 15 | public int Age { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /XamarinWebAPI/Project_Readme.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Your ASP.NET application 6 | 95 | 96 | 97 | 98 | 102 | 103 |
104 |
105 |

This application consists of:

106 |
    107 |
  • Help Page for documenting your Web APIs
  • 108 |
  • Theming using Bootstrap
  • 109 |
  • Authentication, if selected, shows how to register and sign in
  • 110 |
  • ASP.NET features managed using NuGet
  • 111 |
112 |
113 | 114 | 130 | 131 |
132 |

Deploy

133 | 138 |
139 | 140 |
141 |

Get help

142 | 146 |
147 |
148 | 149 | 150 | -------------------------------------------------------------------------------- /XamarinWebAPI/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("XamarinWebAPI")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("XamarinWebAPI")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a4bf6c30-9b4a-431f-a978-a9966d6740cd")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /XamarinWebAPI/Providers/ApplicationOAuthProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Security.Claims; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNet.Identity; 7 | using Microsoft.AspNet.Identity.EntityFramework; 8 | using Microsoft.AspNet.Identity.Owin; 9 | using Microsoft.Owin.Security; 10 | using Microsoft.Owin.Security.Cookies; 11 | using Microsoft.Owin.Security.OAuth; 12 | using XamarinWebAPI.Models; 13 | 14 | namespace XamarinWebAPI.Providers 15 | { 16 | public class ApplicationOAuthProvider : OAuthAuthorizationServerProvider 17 | { 18 | private readonly string _publicClientId; 19 | 20 | public ApplicationOAuthProvider(string publicClientId) 21 | { 22 | if (publicClientId == null) 23 | { 24 | throw new ArgumentNullException("publicClientId"); 25 | } 26 | 27 | _publicClientId = publicClientId; 28 | } 29 | 30 | public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) 31 | { 32 | var userManager = context.OwinContext.GetUserManager(); 33 | 34 | ApplicationUser user = await userManager.FindAsync(context.UserName, context.Password); 35 | 36 | if (user == null) 37 | { 38 | context.SetError("invalid_grant", "The user name or password is incorrect."); 39 | return; 40 | } 41 | 42 | ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(userManager, 43 | OAuthDefaults.AuthenticationType); 44 | ClaimsIdentity cookiesIdentity = await user.GenerateUserIdentityAsync(userManager, 45 | CookieAuthenticationDefaults.AuthenticationType); 46 | 47 | AuthenticationProperties properties = CreateProperties(user.UserName); 48 | AuthenticationTicket ticket = new AuthenticationTicket(oAuthIdentity, properties); 49 | context.Validated(ticket); 50 | context.Request.Context.Authentication.SignIn(cookiesIdentity); 51 | } 52 | 53 | public override Task TokenEndpoint(OAuthTokenEndpointContext context) 54 | { 55 | foreach (KeyValuePair property in context.Properties.Dictionary) 56 | { 57 | context.AdditionalResponseParameters.Add(property.Key, property.Value); 58 | } 59 | 60 | return Task.FromResult(null); 61 | } 62 | 63 | public override Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context) 64 | { 65 | // Resource owner password credentials does not provide a client ID. 66 | if (context.ClientId == null) 67 | { 68 | context.Validated(); 69 | } 70 | 71 | return Task.FromResult(null); 72 | } 73 | 74 | public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context) 75 | { 76 | if (context.ClientId == _publicClientId) 77 | { 78 | Uri expectedRootUri = new Uri(context.Request.Uri, "/"); 79 | 80 | if (expectedRootUri.AbsoluteUri == context.RedirectUri) 81 | { 82 | context.Validated(); 83 | } 84 | } 85 | 86 | return Task.FromResult(null); 87 | } 88 | 89 | public static AuthenticationProperties CreateProperties(string userName) 90 | { 91 | IDictionary data = new Dictionary 92 | { 93 | { "userName", userName } 94 | }; 95 | return new AuthenticationProperties(data); 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /XamarinWebAPI/Results/ChallengeResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Net.Http; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | using System.Web.Http; 9 | 10 | namespace XamarinWebAPI.Results 11 | { 12 | public class ChallengeResult : IHttpActionResult 13 | { 14 | public ChallengeResult(string loginProvider, ApiController controller) 15 | { 16 | LoginProvider = loginProvider; 17 | Request = controller.Request; 18 | } 19 | 20 | public string LoginProvider { get; set; } 21 | public HttpRequestMessage Request { get; set; } 22 | 23 | public Task ExecuteAsync(CancellationToken cancellationToken) 24 | { 25 | Request.GetOwinContext().Authentication.Challenge(LoginProvider); 26 | 27 | HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Unauthorized); 28 | response.RequestMessage = Request; 29 | return Task.FromResult(response); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /XamarinWebAPI/Scripts/_references.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveVoyles/XamarinWebAPI/d8740967136483433908078c5a43e62b5678464e/XamarinWebAPI/Scripts/_references.js -------------------------------------------------------------------------------- /XamarinWebAPI/Scripts/jquery.validate.unobtrusive.min.js: -------------------------------------------------------------------------------- 1 | /* NUGET: BEGIN LICENSE TEXT 2 | * 3 | * Microsoft grants you the right to use these script files for the sole 4 | * purpose of either: (i) interacting through your browser with the Microsoft 5 | * website or online service, subject to the applicable licensing or use 6 | * terms; or (ii) using the files as included with a Microsoft product subject 7 | * to that product's license terms. Microsoft reserves all other rights to the 8 | * files not expressly granted by Microsoft, whether by implication, estoppel 9 | * or otherwise. Insofar as a script file is dual licensed under GPL, 10 | * Microsoft neither took the code under GPL nor distributes it thereunder but 11 | * under the terms set out in this paragraph. All notices and licenses 12 | * below are for informational purposes only. 13 | * 14 | * NUGET: END LICENSE TEXT */ 15 | /* 16 | ** Unobtrusive validation support library for jQuery and jQuery Validate 17 | ** Copyright (C) Microsoft Corporation. All rights reserved. 18 | */ 19 | (function(a){var d=a.validator,b,e="unobtrusiveValidation";function c(a,b,c){a.rules[b]=c;if(a.message)a.messages[b]=a.message}function j(a){return a.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function f(a){return a.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g,"\\$1")}function h(a){return a.substr(0,a.lastIndexOf(".")+1)}function g(a,b){if(a.indexOf("*.")===0)a=a.replace("*.",b);return a}function m(c,e){var b=a(this).find("[data-valmsg-for='"+f(e[0].name)+"']"),d=b.attr("data-valmsg-replace"),g=d?a.parseJSON(d)!==false:null;b.removeClass("field-validation-valid").addClass("field-validation-error");c.data("unobtrusiveContainer",b);if(g){b.empty();c.removeClass("input-validation-error").appendTo(b)}else c.hide()}function l(e,d){var c=a(this).find("[data-valmsg-summary=true]"),b=c.find("ul");if(b&&b.length&&d.errorList.length){b.empty();c.addClass("validation-summary-errors").removeClass("validation-summary-valid");a.each(d.errorList,function(){a("
  • ").html(this.message).appendTo(b)})}}function k(d){var b=d.data("unobtrusiveContainer"),c=b.attr("data-valmsg-replace"),e=c?a.parseJSON(c):null;if(b){b.addClass("field-validation-valid").removeClass("field-validation-error");d.removeData("unobtrusiveContainer");e&&b.empty()}}function n(){var b=a(this);b.data("validator").resetForm();b.find(".validation-summary-errors").addClass("validation-summary-valid").removeClass("validation-summary-errors");b.find(".field-validation-error").addClass("field-validation-valid").removeClass("field-validation-error").removeData("unobtrusiveContainer").find(">*").removeData("unobtrusiveContainer")}function i(b){var c=a(b),f=c.data(e),i=a.proxy(n,b),g=d.unobtrusive.options||{},h=function(e,d){var c=g[e];c&&a.isFunction(c)&&c.apply(b,d)};if(!f){f={options:{errorClass:g.errorClass||"input-validation-error",errorElement:g.errorElement||"span",errorPlacement:function(){m.apply(b,arguments);h("errorPlacement",arguments)},invalidHandler:function(){l.apply(b,arguments);h("invalidHandler",arguments)},messages:{},rules:{},success:function(){k.apply(b,arguments);h("success",arguments)}},attachValidation:function(){c.off("reset."+e,i).on("reset."+e,i).validate(this.options)},validate:function(){c.validate();return c.valid()}};c.data(e,f)}return f}d.unobtrusive={adapters:[],parseElement:function(b,h){var d=a(b),f=d.parents("form")[0],c,e,g;if(!f)return;c=i(f);c.options.rules[b.name]=e={};c.options.messages[b.name]=g={};a.each(this.adapters,function(){var c="data-val-"+this.name,i=d.attr(c),h={};if(i!==undefined){c+="-";a.each(this.params,function(){h[this]=d.attr(c+this)});this.adapt({element:b,form:f,message:i,params:h,rules:e,messages:g})}});a.extend(e,{__dummy__:true});!h&&c.attachValidation()},parse:function(c){var b=a(c),e=b.parents().addBack().filter("form").add(b.find("form")).has("[data-val=true]");b.find("[data-val=true]").each(function(){d.unobtrusive.parseElement(this,true)});e.each(function(){var a=i(this);a&&a.attachValidation()})}};b=d.unobtrusive.adapters;b.add=function(c,a,b){if(!b){b=a;a=[]}this.push({name:c,params:a,adapt:b});return this};b.addBool=function(a,b){return this.add(a,function(d){c(d,b||a,true)})};b.addMinMax=function(e,g,f,a,d,b){return this.add(e,[d||"min",b||"max"],function(b){var e=b.params.min,d=b.params.max;if(e&&d)c(b,a,[e,d]);else if(e)c(b,g,e);else d&&c(b,f,d)})};b.addSingleVal=function(a,b,d){return this.add(a,[b||"val"],function(e){c(e,d||a,e.params[b])})};d.addMethod("__dummy__",function(){return true});d.addMethod("regex",function(b,c,d){var a;if(this.optional(c))return true;a=(new RegExp(d)).exec(b);return a&&a.index===0&&a[0].length===b.length});d.addMethod("nonalphamin",function(c,d,b){var a;if(b){a=c.match(/\W/g);a=a&&a.length>=b}return a});if(d.methods.extension){b.addSingleVal("accept","mimtype");b.addSingleVal("extension","extension")}else b.addSingleVal("extension","extension","accept");b.addSingleVal("regex","pattern");b.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url");b.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range");b.addMinMax("minlength","minlength").addMinMax("maxlength","minlength","maxlength");b.add("equalto",["other"],function(b){var i=h(b.element.name),j=b.params.other,d=g(j,i),e=a(b.form).find(":input").filter("[name='"+f(d)+"']")[0];c(b,"equalTo",e)});b.add("required",function(a){(a.element.tagName.toUpperCase()!=="INPUT"||a.element.type.toUpperCase()!=="CHECKBOX")&&c(a,"required",true)});b.add("remote",["url","type","additionalfields"],function(b){var d={url:b.params.url,type:b.params.type||"GET",data:{}},e=h(b.element.name);a.each(j(b.params.additionalfields||b.element.name),function(i,h){var c=g(h,e);d.data[c]=function(){return a(b.form).find(":input").filter("[name='"+f(c)+"']").val()}});c(b,"remote",d)});b.add("password",["min","nonalphamin","regex"],function(a){a.params.min&&c(a,"minlength",a.params.min);a.params.nonalphamin&&c(a,"nonalphamin",a.params.nonalphamin);a.params.regex&&c(a,"regex",a.params.regex)});a(function(){d.unobtrusive.parse(document)})})(jQuery); -------------------------------------------------------------------------------- /XamarinWebAPI/Scripts/respond.min.js: -------------------------------------------------------------------------------- 1 | /* NUGET: BEGIN LICENSE TEXT 2 | * 3 | * Microsoft grants you the right to use these script files for the sole 4 | * purpose of either: (i) interacting through your browser with the Microsoft 5 | * website or online service, subject to the applicable licensing or use 6 | * terms; or (ii) using the files as included with a Microsoft product subject 7 | * to that product's license terms. Microsoft reserves all other rights to the 8 | * files not expressly granted by Microsoft, whether by implication, estoppel 9 | * or otherwise. Insofar as a script file is dual licensed under GPL, 10 | * Microsoft neither took the code under GPL nor distributes it thereunder but 11 | * under the terms set out in this paragraph. All notices and licenses 12 | * below are for informational purposes only. 13 | * 14 | * NUGET: END LICENSE TEXT */ 15 | /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */ 16 | /*! NOTE: If you're already including a window.matchMedia polyfill via Modernizr or otherwise, you don't need this part */ 17 | window.matchMedia=window.matchMedia||(function(e,f){var c,a=e.documentElement,b=a.firstElementChild||a.firstChild,d=e.createElement("body"),g=e.createElement("div");g.id="mq-test-1";g.style.cssText="position:absolute;top:-100em";d.style.background="none";d.appendChild(g);return function(h){g.innerHTML='­';a.insertBefore(d,b);c=g.offsetWidth==42;a.removeChild(d);return{matches:c,media:h}}})(document); 18 | 19 | /*! Respond.js v1.2.0: min/max-width media query polyfill. (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs */ 20 | (function(e){e.respond={};respond.update=function(){};respond.mediaQueriesSupported=e.matchMedia&&e.matchMedia("only all").matches;if(respond.mediaQueriesSupported){return}var w=e.document,s=w.documentElement,i=[],k=[],q=[],o={},h=30,f=w.getElementsByTagName("head")[0]||s,g=w.getElementsByTagName("base")[0],b=f.getElementsByTagName("link"),d=[],a=function(){var D=b,y=D.length,B=0,A,z,C,x;for(;B-1,minw:F.match(/\(min\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:F.match(/\(max\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}}j()},l,r,v=function(){var z,A=w.createElement("div"),x=w.body,y=false;A.style.cssText="position:absolute;font-size:1em;width:1em";if(!x){x=y=w.createElement("body");x.style.background="none"}x.appendChild(A);s.insertBefore(x,s.firstChild);z=A.offsetWidth;if(y){s.removeChild(x)}else{x.removeChild(A)}z=p=parseFloat(z);return z},p,j=function(I){var x="clientWidth",B=s[x],H=w.compatMode==="CSS1Compat"&&B||w.body[x]||B,D={},G=b[b.length-1],z=(new Date()).getTime();if(I&&l&&z-l-1?(p||v()):1)}if(!!J){J=parseFloat(J)*(J.indexOf(y)>-1?(p||v()):1)}if(!K.hasquery||(!A||!L)&&(A||H>=C)&&(L||H<=J)){if(!D[K.media]){D[K.media]=[]}D[K.media].push(k[K.rules])}}for(var E in q){if(q[E]&&q[E].parentNode===f){f.removeChild(q[E])}}for(var E in D){var M=w.createElement("style"),F=D[E].join("\n");M.type="text/css";M.media=E;f.insertBefore(M,G.nextSibling);if(M.styleSheet){M.styleSheet.cssText=F}else{M.appendChild(w.createTextNode(F))}q.push(M)}},n=function(x,z){var y=c();if(!y){return}y.open("GET",x,true);y.onreadystatechange=function(){if(y.readyState!=4||y.status!=200&&y.status!=304){return}z(y.responseText)};if(y.readyState==4){return}y.send(null)},c=(function(){var x=false;try{x=new XMLHttpRequest()}catch(y){x=new ActiveXObject("Microsoft.XMLHTTP")}return function(){return x}})();a();respond.update=a;function t(){j(true)}if(e.addEventListener){e.addEventListener("resize",t,false)}else{if(e.attachEvent){e.attachEvent("onresize",t)}}})(this); -------------------------------------------------------------------------------- /XamarinWebAPI/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Microsoft.Owin; 5 | using Owin; 6 | 7 | [assembly: OwinStartup(typeof(XamarinWebAPI.Startup))] 8 | 9 | namespace XamarinWebAPI 10 | { 11 | public partial class Startup 12 | { 13 | public void Configuration(IAppBuilder app) 14 | { 15 | ConfigureAuth(app); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /XamarinWebAPI/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | 
    2 |

    ASP.NET

    3 |

    ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS, and JavaScript.

    4 |

    Learn more »

    5 |
    6 |
    7 |
    8 |

    Getting started

    9 |

    ASP.NET Web API is a framework that makes it easy to build HTTP services that reach 10 | a broad range of clients, including browsers and mobile devices. ASP.NET Web API 11 | is an ideal platform for building RESTful applications on the .NET Framework.

    12 |

    Learn more »

    13 |
    14 |
    15 |

    Get more libraries

    16 |

    NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.

    17 |

    Learn more »

    18 |
    19 |
    20 |

    Web Hosting

    21 |

    You can easily find a web hosting company that offers the right mix of features and price for your applications.

    22 |

    Learn more »

    23 |
    24 |
    25 | -------------------------------------------------------------------------------- /XamarinWebAPI/Views/Person/Create.cshtml: -------------------------------------------------------------------------------- 1 | @model XamarinWebAPI.Models.Person 2 | 3 | @{ 4 | ViewBag.Title = "Create"; 5 | } 6 | 7 |

    Create

    8 | 9 | 10 | @using (Html.BeginForm()) 11 | { 12 | @Html.AntiForgeryToken() 13 | 14 |
    15 |

    Person

    16 |
    17 | @Html.ValidationSummary(true, "", new { @class = "text-danger" }) 18 |
    19 | @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" }) 20 |
    21 | @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } }) 22 | @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" }) 23 |
    24 |
    25 | 26 |
    27 | @Html.LabelFor(model => model.Age, htmlAttributes: new { @class = "control-label col-md-2" }) 28 |
    29 | @Html.EditorFor(model => model.Age, new { htmlAttributes = new { @class = "form-control" } }) 30 | @Html.ValidationMessageFor(model => model.Age, "", new { @class = "text-danger" }) 31 |
    32 |
    33 | 34 |
    35 |
    36 | 37 |
    38 |
    39 |
    40 | } 41 | 42 |
    43 | @Html.ActionLink("Back to List", "Index") 44 |
    45 | 46 | @section Scripts { 47 | @Scripts.Render("~/bundles/jqueryval") 48 | } 49 | -------------------------------------------------------------------------------- /XamarinWebAPI/Views/Person/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @model XamarinWebAPI.Models.Person 2 | 3 | @{ 4 | ViewBag.Title = "Delete"; 5 | } 6 | 7 |

    Delete

    8 | 9 |

    Are you sure you want to delete this?

    10 |
    11 |

    Person

    12 |
    13 |
    14 |
    15 | @Html.DisplayNameFor(model => model.Name) 16 |
    17 | 18 |
    19 | @Html.DisplayFor(model => model.Name) 20 |
    21 | 22 |
    23 | @Html.DisplayNameFor(model => model.Age) 24 |
    25 | 26 |
    27 | @Html.DisplayFor(model => model.Age) 28 |
    29 | 30 |
    31 | 32 | @using (Html.BeginForm()) { 33 | @Html.AntiForgeryToken() 34 | 35 |
    36 | | 37 | @Html.ActionLink("Back to List", "Index") 38 |
    39 | } 40 |
    41 | -------------------------------------------------------------------------------- /XamarinWebAPI/Views/Person/Details.cshtml: -------------------------------------------------------------------------------- 1 | @model XamarinWebAPI.Models.Person 2 | 3 | @{ 4 | ViewBag.Title = "Details"; 5 | } 6 | 7 |

    Details

    8 | 9 |
    10 |

    Person

    11 |
    12 |
    13 |
    14 | @Html.DisplayNameFor(model => model.Name) 15 |
    16 | 17 |
    18 | @Html.DisplayFor(model => model.Name) 19 |
    20 | 21 |
    22 | @Html.DisplayNameFor(model => model.Age) 23 |
    24 | 25 |
    26 | @Html.DisplayFor(model => model.Age) 27 |
    28 | 29 |
    30 |
    31 |

    32 | @Html.ActionLink("Edit", "Edit", new { id = Model.Id }) | 33 | @Html.ActionLink("Back to List", "Index") 34 |

    35 | -------------------------------------------------------------------------------- /XamarinWebAPI/Views/Person/Edit.cshtml: -------------------------------------------------------------------------------- 1 | @model XamarinWebAPI.Models.Person 2 | 3 | @{ 4 | ViewBag.Title = "Edit"; 5 | } 6 | 7 |

    Edit

    8 | 9 | 10 | @using (Html.BeginForm()) 11 | { 12 | @Html.AntiForgeryToken() 13 | 14 |
    15 |

    Person

    16 |
    17 | @Html.ValidationSummary(true, "", new { @class = "text-danger" }) 18 | @Html.HiddenFor(model => model.Id) 19 | 20 |
    21 | @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" }) 22 |
    23 | @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } }) 24 | @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" }) 25 |
    26 |
    27 | 28 |
    29 | @Html.LabelFor(model => model.Age, htmlAttributes: new { @class = "control-label col-md-2" }) 30 |
    31 | @Html.EditorFor(model => model.Age, new { htmlAttributes = new { @class = "form-control" } }) 32 | @Html.ValidationMessageFor(model => model.Age, "", new { @class = "text-danger" }) 33 |
    34 |
    35 | 36 |
    37 |
    38 | 39 |
    40 |
    41 |
    42 | } 43 | 44 |
    45 | @Html.ActionLink("Back to List", "Index") 46 |
    47 | 48 | @section Scripts { 49 | @Scripts.Render("~/bundles/jqueryval") 50 | } 51 | -------------------------------------------------------------------------------- /XamarinWebAPI/Views/Person/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewBag.Title = "Index"; 5 | } 6 | 7 |

    Index

    8 | 9 |

    10 | @Html.ActionLink("Create New", "Create") 11 |

    12 | 13 | 14 | 17 | 20 | 21 | 22 | 23 | @foreach (var item in Model) { 24 | 25 | 28 | 31 | 36 | 37 | } 38 | 39 |
    15 | @Html.DisplayNameFor(model => model.Name) 16 | 18 | @Html.DisplayNameFor(model => model.Age) 19 |
    26 | @Html.DisplayFor(modelItem => item.Name) 27 | 29 | @Html.DisplayFor(modelItem => item.Age) 30 | 32 | @Html.ActionLink("Edit", "Edit", new { id=item.Id }) | 33 | @Html.ActionLink("Details", "Details", new { id=item.Id }) | 34 | @Html.ActionLink("Delete", "Delete", new { id=item.Id }) 35 |
    40 | -------------------------------------------------------------------------------- /XamarinWebAPI/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = null; 3 | } 4 | 5 | 6 | 7 | 8 | 9 | Error 10 | 11 | 12 |
    13 |

    Error.

    14 |

    An error occurred while processing your request.

    15 |
    16 | 17 | 18 | -------------------------------------------------------------------------------- /XamarinWebAPI/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewBag.Title 7 | @Styles.Render("~/Content/css") 8 | @Scripts.Render("~/bundles/modernizr") 9 | 10 | 11 | 29 |
    30 | @RenderBody() 31 |
    32 |
    33 |

    © @DateTime.Now.Year - My ASP.NET Application

    34 |
    35 |
    36 | 37 | @Scripts.Render("~/bundles/jquery") 38 | @Scripts.Render("~/bundles/bootstrap") 39 | @RenderSection("scripts", required: false) 40 | 41 | 42 | -------------------------------------------------------------------------------- /XamarinWebAPI/Views/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 |
    7 |
    8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /XamarinWebAPI/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /XamarinWebAPI/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /XamarinWebAPI/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /XamarinWebAPI/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 |
    10 | 11 | 12 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /XamarinWebAPI/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveVoyles/XamarinWebAPI/d8740967136483433908078c5a43e62b5678464e/XamarinWebAPI/favicon.ico -------------------------------------------------------------------------------- /XamarinWebAPI/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveVoyles/XamarinWebAPI/d8740967136483433908078c5a43e62b5678464e/XamarinWebAPI/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /XamarinWebAPI/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveVoyles/XamarinWebAPI/d8740967136483433908078c5a43e62b5678464e/XamarinWebAPI/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /XamarinWebAPI/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveVoyles/XamarinWebAPI/d8740967136483433908078c5a43e62b5678464e/XamarinWebAPI/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /XamarinWebAPI/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Xamarin_Web_API_iOS/Components/restsharp-104.1.0.info: -------------------------------------------------------------------------------- 1 | {"Name":"RestSharp","Id":163,"Alias":"restsharp","Description":"RestSharp makes it easy to consume the wide array of services on the web over HTTP, like: Amazon, Facebook, or even Twitter...\n\n## Features\n\n* Automatic XML and JSON deserialization\n* Supports custom serialization and deserialization via ISerializer and IDeserializer\n* Fuzzy element name matching (\u0027product_id\u0027 in XML/JSON will match C# property named \u0027ProductId\u0027)\n* Automatic detection of type of content returned\n* GET, POST, PUT, HEAD, OPTIONS, DELETE supported\n* Other non-standard HTTP methods also supported\n* oAuth 1, oAuth 2, Basic, NTLM and Parameter-based Authenticators included\n* Supports custom authentication schemes via IAuthenticator\n* Multi-part form/file uploads\n* T4 Helper to generate C# classes from an XML document\n\n## Example\n\n```csharp\nusing RestSharp;\n// ...\n\nvar client = new RestClient (\"http://rxnav.nlm.nih.gov/REST/RxTerms/rxcui/\");\n\nvar request = new RestRequest (String.Format (\"{0}/allinfo\", \"198440\"));\nclient.ExecuteAsync (request, response =\u003e {\n\tConsole.WriteLine (response.Content);\n});\n```","Version":"104.1.0","Summary":"A simple REST client for consuming HTTP APIs.","QuickStart":"## Example\n\n```csharp\nusing RestSharp;\n// ...\n\nvar client = new RestClient (\"http://rxnav.nlm.nih.gov/REST/RxTerms/rxcui/\");\n\nvar request = new RestRequest (String.Format (\"{0}/allinfo\", \"198440\"));\nclient.ExecuteAsync (request, response =\u003e {\n\tConsole.WriteLine (response.Content);\n});\n```\n\n## Features\n```csharp\nvar client = new RestClient(\"http://example.com\");\n// client.Authenticator = new HttpBasicAuthenticator(username, password);\n\nvar request = new RestRequest(\"resource/{id}\", Method.POST);\nrequest.AddParameter(\"name\", \"value\"); // adds to POST or URL querystring based on Method\nrequest.AddUrlSegment(\"id\", 123); // replaces matching token in request.Resource\n\n// add parameters for all properties on an object\nrequest.AddObject(object);\n\n// or just whitelisted properties\nrequest.AddObject(object, \"PersonId\", \"Name\", ...);\n\n// easily add HTTP Headers\nrequest.AddHeader(\"header\", \"value\");\n\n// add files to upload (works with compatible verbs)\nrequest.AddFile(path);\n\n// execute the request\nRestResponse response = client.Execute(request);\nvar content = response.Content; // raw content as string\n\n// or automatically deserialize result\n// return content type is sniffed but can be explicitly set via RestClient.AddHandler();\nRestResponse\u003cPerson\u003e response2 = client.Execute\u003cPerson\u003e(request);\nvar name = response2.Data.Name;\n\n// or download and save file to disk\nclient.DownloadData(request).SaveAs(path);\n\n// easy async support\nclient.ExecuteAsync(request, response =\u003e {\n Console.WriteLine(response.Content);\n});\n\n// async with deserialization\nvar asyncHandle = client.ExecuteAsync\u003cPerson\u003e(request, response =\u003e {\n Console.WriteLine(response.Data.Name);\n});\n\n// abort the request on demand\nasyncHandle.Abort();\n```\n\n## Documentation\n\n- Wiki: [https://github.com/restsharp/RestSharp/wiki](https://github.com/restsharp/RestSharp/wiki)\n\n## Contact / Discuss\n\n- Please use the [Google Group](http://groups.google.com/group/RestSharp) for feature requests and troubleshooting usage.\n- Twitter: [@RestSharp](http://twitter.com/restsharp)","Hash":"042cc650db3eba8c1575fb9622ef6f71","TargetPlatforms":["ios","android"],"TrialHash":null} -------------------------------------------------------------------------------- /Xamarin_Web_API_iOS/Components/restsharp-104.1.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveVoyles/XamarinWebAPI/d8740967136483433908078c5a43e62b5678464e/Xamarin_Web_API_iOS/Components/restsharp-104.1.0.png -------------------------------------------------------------------------------- /Xamarin_Web_API_iOS/Components/restsharp-104.1.0/lib/ios/RestSharp.MonoTouch.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveVoyles/XamarinWebAPI/d8740967136483433908078c5a43e62b5678464e/Xamarin_Web_API_iOS/Components/restsharp-104.1.0/lib/ios/RestSharp.MonoTouch.dll -------------------------------------------------------------------------------- /Xamarin_Web_API_iOS/Components/restsharp-105.0.1.0.info: -------------------------------------------------------------------------------- 1 | {"Name":"RestSharp","Id":1402,"Alias":"restsharp","Description":"RestSharp makes it easy to consume the wide array of services on the web over HTTP, like: Amazon, Facebook, or even Twitter...\n\n## Features\n\n* Automatic XML and JSON deserialization\n* Supports custom serialization and deserialization via ISerializer and IDeserializer\n* Fuzzy element name matching (\u0027product_id\u0027 in XML/JSON will match C# property named \u0027ProductId\u0027)\n* Automatic detection of type of content returned\n* GET, POST, PUT, HEAD, OPTIONS, DELETE supported\n* Other non-standard HTTP methods also supported\n* oAuth 1, oAuth 2, Basic, NTLM and Parameter-based Authenticators included\n* Supports custom authentication schemes via IAuthenticator\n* Multi-part form/file uploads\n* T4 Helper to generate C# classes from an XML document\n\n## Example\n\n```csharp\nusing RestSharp;\n// ...\n\nvar client = new RestClient (\"http://rxnav.nlm.nih.gov/REST/RxTerms/rxcui/\");\n\nvar request = new RestRequest (String.Format (\"{0}/allinfo\", \"198440\"));\nclient.ExecuteAsync (request, response =\u003e {\n\tConsole.WriteLine (response.Content);\n});\n```","Version":"105.0.1.0","Summary":"A simple REST client for consuming HTTP APIs.","QuickStart":"## Example\n\n```csharp\nusing RestSharp;\n// ...\n\nvar client = new RestClient (\"http://rxnav.nlm.nih.gov/REST/RxTerms/rxcui/\");\n\nvar request = new RestRequest (String.Format (\"{0}/allinfo\", \"198440\"));\nclient.ExecuteAsync (request, response =\u003e {\n\tConsole.WriteLine (response.Content);\n});\n```\n\n## Features\n```csharp\nvar client = new RestClient(\"http://example.com\");\n// client.Authenticator = new HttpBasicAuthenticator(username, password);\n\nvar request = new RestRequest(\"resource/{id}\", Method.POST);\nrequest.AddParameter(\"name\", \"value\"); // adds to POST or URL querystring based on Method\nrequest.AddUrlSegment(\"id\", 123); // replaces matching token in request.Resource\n\n// add parameters for all properties on an object\nrequest.AddObject(object);\n\n// or just whitelisted properties\nrequest.AddObject(object, \"PersonId\", \"Name\", ...);\n\n// easily add HTTP Headers\nrequest.AddHeader(\"header\", \"value\");\n\n// add files to upload (works with compatible verbs)\nrequest.AddFile(path);\n\n// execute the request\nRestResponse response = client.Execute(request);\nvar content = response.Content; // raw content as string\n\n// or automatically deserialize result\n// return content type is sniffed but can be explicitly set via RestClient.AddHandler();\nRestResponse\u003cPerson\u003e response2 = client.Execute\u003cPerson\u003e(request);\nvar name = response2.Data.Name;\n\n// or download and save file to disk\nclient.DownloadData(request).SaveAs(path);\n\n// easy async support\nclient.ExecuteAsync(request, response =\u003e {\n Console.WriteLine(response.Content);\n});\n\n// async with deserialization\nvar asyncHandle = client.ExecuteAsync\u003cPerson\u003e(request, response =\u003e {\n Console.WriteLine(response.Data.Name);\n});\n\n// abort the request on demand\nasyncHandle.Abort();\n```\n\n## Documentation\n\n- Wiki: [https://github.com/restsharp/RestSharp/wiki](https://github.com/restsharp/RestSharp/wiki)\n\n## Contact / Discuss\n\n- Please use the [Google Group](http://groups.google.com/group/RestSharp) for feature requests and troubleshooting usage.\n- Twitter: [@RestSharp](http://twitter.com/restsharp)","Hash":"35f15bfecdd327071acde8855129612c","TargetPlatforms":["ios","android"],"TrialHash":null} -------------------------------------------------------------------------------- /Xamarin_Web_API_iOS/Components/restsharp-105.0.1.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveVoyles/XamarinWebAPI/d8740967136483433908078c5a43e62b5678464e/Xamarin_Web_API_iOS/Components/restsharp-105.0.1.0.png -------------------------------------------------------------------------------- /Xamarin_Web_API_iOS/Components/restsharp-105.0.1.0/component/Details.md: -------------------------------------------------------------------------------- 1 | RestSharp makes it easy to consume the wide array of services on the web over HTTP, like: Amazon, Facebook, or even Twitter... 2 | 3 | ## Features 4 | 5 | * Automatic XML and JSON deserialization 6 | * Supports custom serialization and deserialization via ISerializer and IDeserializer 7 | * Fuzzy element name matching ('product_id' in XML/JSON will match C# property named 'ProductId') 8 | * Automatic detection of type of content returned 9 | * GET, POST, PUT, HEAD, OPTIONS, DELETE supported 10 | * Other non-standard HTTP methods also supported 11 | * oAuth 1, oAuth 2, Basic, NTLM and Parameter-based Authenticators included 12 | * Supports custom authentication schemes via IAuthenticator 13 | * Multi-part form/file uploads 14 | * T4 Helper to generate C# classes from an XML document 15 | 16 | ## Example 17 | 18 | ```csharp 19 | using RestSharp; 20 | // ... 21 | 22 | var client = new RestClient ("http://rxnav.nlm.nih.gov/REST/RxTerms/rxcui/"); 23 | 24 | var request = new RestRequest (String.Format ("{0}/allinfo", "198440")); 25 | client.ExecuteAsync (request, response => { 26 | Console.WriteLine (response.Content); 27 | }); 28 | ``` -------------------------------------------------------------------------------- /Xamarin_Web_API_iOS/Components/restsharp-105.0.1.0/component/GettingStarted.md: -------------------------------------------------------------------------------- 1 | ## Example 2 | 3 | ```csharp 4 | using RestSharp; 5 | // ... 6 | 7 | var client = new RestClient ("http://rxnav.nlm.nih.gov/REST/RxTerms/rxcui/"); 8 | 9 | var request = new RestRequest (String.Format ("{0}/allinfo", "198440")); 10 | client.ExecuteAsync (request, response => { 11 | Console.WriteLine (response.Content); 12 | }); 13 | ``` 14 | 15 | ## Features 16 | ```csharp 17 | var client = new RestClient("http://example.com"); 18 | // client.Authenticator = new HttpBasicAuthenticator(username, password); 19 | 20 | var request = new RestRequest("resource/{id}", Method.POST); 21 | request.AddParameter("name", "value"); // adds to POST or URL querystring based on Method 22 | request.AddUrlSegment("id", 123); // replaces matching token in request.Resource 23 | 24 | // add parameters for all properties on an object 25 | request.AddObject(object); 26 | 27 | // or just whitelisted properties 28 | request.AddObject(object, "PersonId", "Name", ...); 29 | 30 | // easily add HTTP Headers 31 | request.AddHeader("header", "value"); 32 | 33 | // add files to upload (works with compatible verbs) 34 | request.AddFile(path); 35 | 36 | // execute the request 37 | RestResponse response = client.Execute(request); 38 | var content = response.Content; // raw content as string 39 | 40 | // or automatically deserialize result 41 | // return content type is sniffed but can be explicitly set via RestClient.AddHandler(); 42 | RestResponse response2 = client.Execute(request); 43 | var name = response2.Data.Name; 44 | 45 | // or download and save file to disk 46 | client.DownloadData(request).SaveAs(path); 47 | 48 | // easy async support 49 | client.ExecuteAsync(request, response => { 50 | Console.WriteLine(response.Content); 51 | }); 52 | 53 | // async with deserialization 54 | var asyncHandle = client.ExecuteAsync(request, response => { 55 | Console.WriteLine(response.Data.Name); 56 | }); 57 | 58 | // abort the request on demand 59 | asyncHandle.Abort(); 60 | ``` 61 | 62 | ## Documentation 63 | 64 | - Wiki: [https://github.com/restsharp/RestSharp/wiki](https://github.com/restsharp/RestSharp/wiki) 65 | 66 | ## Contact / Discuss 67 | 68 | - Please use the [Google Group](http://groups.google.com/group/RestSharp) for feature requests and troubleshooting usage. 69 | - Twitter: [@RestSharp](http://twitter.com/restsharp) -------------------------------------------------------------------------------- /Xamarin_Web_API_iOS/Components/restsharp-105.0.1.0/component/Manifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | RestSharp 4 | John Sheehan 5 | http://restsharp.org/ 6 | 105.0.1.0 7 | A simple REST client for consuming HTTP APIs. 8 | 9 | 10 | Android Sample 11 | Android Sample 12 | 13 | 14 | iOS Unified Sample 15 | iOS Unified Sample 16 | 17 | 18 | iOS Classic Sample 19 | iOS Classic Sample 20 | 21 | 22 | -------------------------------------------------------------------------------- /Xamarin_Web_API_iOS/Components/restsharp-105.0.1.0/component/icons/restsharp_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveVoyles/XamarinWebAPI/d8740967136483433908078c5a43e62b5678464e/Xamarin_Web_API_iOS/Components/restsharp-105.0.1.0/component/icons/restsharp_128x128.png -------------------------------------------------------------------------------- /Xamarin_Web_API_iOS/Components/restsharp-105.0.1.0/lib/android/RestSharp.MonoDroid.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveVoyles/XamarinWebAPI/d8740967136483433908078c5a43e62b5678464e/Xamarin_Web_API_iOS/Components/restsharp-105.0.1.0/lib/android/RestSharp.MonoDroid.dll -------------------------------------------------------------------------------- /Xamarin_Web_API_iOS/Components/restsharp-105.0.1.0/lib/ios-unified/RestSharp.MonoTouch.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveVoyles/XamarinWebAPI/d8740967136483433908078c5a43e62b5678464e/Xamarin_Web_API_iOS/Components/restsharp-105.0.1.0/lib/ios-unified/RestSharp.MonoTouch.dll -------------------------------------------------------------------------------- /Xamarin_Web_API_iOS/Components/restsharp-105.0.1.0/lib/ios/RestSharp.MonoTouch.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveVoyles/XamarinWebAPI/d8740967136483433908078c5a43e62b5678464e/Xamarin_Web_API_iOS/Components/restsharp-105.0.1.0/lib/ios/RestSharp.MonoTouch.dll -------------------------------------------------------------------------------- /Xamarin_Web_API_iOS/Components/restsharp-105.0.1.0/samples/RestSharp.Android.Sample/MainActivity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Android.App; 4 | using Android.Content; 5 | using Android.Runtime; 6 | using Android.Views; 7 | using Android.Widget; 8 | using Android.OS; 9 | 10 | namespace RestSharp.Android.Sample 11 | { 12 | [Activity(Label = "RestSharp.Android.Sample", MainLauncher = true, Icon = "@drawable/icon")] 13 | public class MainActivity : Activity 14 | { 15 | private readonly RestClient restClient = new RestClient (@"http://rxnav.nlm.nih.gov/REST/RxTerms/rxcui/"); 16 | private void StartRestRequestAsync() 17 | { 18 | Task.Factory.StartNew (() => { 19 | var rxcui = "198440"; 20 | var request = new RestRequest (String.Format ("{0}/allinfo", rxcui)); 21 | request.RequestFormat = DataFormat.Json; 22 | 23 | return this.restClient.Execute (request); 24 | }).ContinueWith (t => { 25 | text.Text = t.Result.Content; 26 | }, uiScheduler); 27 | } 28 | 29 | private readonly TaskScheduler uiScheduler = TaskScheduler.FromCurrentSynchronizationContext(); 30 | private TextView text; 31 | protected override void OnCreate(Bundle bundle) 32 | { 33 | base.OnCreate (bundle); 34 | SetContentView (Resource.Layout.Main); 35 | 36 | text = FindViewById (Resource.Id.Text); 37 | 38 | FindViewById