Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@ -0,0 +1,33 @@
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
namespace System.Web.Http.ApiExplorer
{
public class DocumentationController : ApiController
{
[ApiDocumentation("Get action")]
public string Get()
{
return string.Empty;
}
[ApiDocumentation("Post action")]
[ApiParameterDocumentation("value", "value parameter")]
public void Post(string value)
{
}
[ApiDocumentation("Put action")]
[ApiParameterDocumentation("id", "id parameter")]
[ApiParameterDocumentation("value", "value parameter")]
public void Put(int id, string value)
{
}
[ApiDocumentation("Delete action")]
[ApiParameterDocumentation("id", "id parameter")]
public void Delete(int id)
{
}
}
}

View File

@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Web.Http.Description;
namespace System.Web.Http.ApiExplorer
{
public class HiddenActionController : ApiController
{
public string GetVisibleAction(int id)
{
return "visible action";
}
[HttpPost]
[ApiExplorerSettings(IgnoreApi = true)]
public void AddData()
{
}
[ApiExplorerSettings(IgnoreApi = true)]
public int Get()
{
return 0;
}
[NonAction]
public string GetHiddenAction()
{
return "Hidden action";
}
}
}

View File

@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Web.Http.Description;
namespace System.Web.Http.ApiExplorer
{
[ApiExplorerSettings(IgnoreApi = true)]
public class HiddenController : ApiController
{
public string Get(int id)
{
return "visible action";
}
[HttpPost]
public void AddData()
{
}
public int Get()
{
return 0;
}
[NonAction]
public string GetHiddenAction()
{
return "Hidden action";
}
}
}

View File

@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
namespace System.Web.Http.ApiExplorer
{
public class ItemController : ApiController
{
public Item GetItem(string name, int series)
{
return new Item()
{
Name = name,
Series = series
};
}
[HttpPost]
[HttpPut]
public Item PostItem(Item item)
{
return item;
}
[HttpDelete]
public void RemoveItem(int id)
{
}
public class Item
{
public int Series { get; set; }
public string Name { get; set; }
}
}
}

View File

@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Collections.Generic;
namespace System.Web.Http.ApiExplorer
{
public class OverloadsController : ApiController
{
public Person Get(int id) { return null; }
public List<Person> Get() { return null; }
public List<Person> Get(string name) { return null; }
public Person GetPersonByNameAndId(string name, int id) { return null; }
public Person GetPersonByNameAndAge(string name, int age) { return null; }
public Person GetPersonByNameAgeAndSsn(string name, int age, int ssn) { return null; }
public Person GetPersonByNameIdAndSsn(string name, int id, int ssn) { return null; }
public Person GetPersonByNameAndSsn(string name, int ssn) { return null; }
public Person Post(Person Person) { return null; }
public Person ActionDefaultedToPost(string name, int age) { return null; }
public void Delete(int id, string name = "Default Name") { }
public void Delete(int id, string name, int age) { }
public class Person
{
public string Name { get; set; }
public int ID { get; set; }
public int SSN { get; set; }
public int Age { get; set; }
}
}
}

View File

@ -0,0 +1,60 @@
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Linq;
using System.Web.Http.ModelBinding;
using System.Web.Http.ValueProviders;
namespace System.Web.Http.ApiExplorer
{
public class ParameterSourceController : ApiController
{
public void GetCompleTypeFromUri([FromUri]ComplexType value, string name)
{
}
public void PostSimpleTypeFromBody([FromBody] string name)
{
}
public void GetCustomFromUriAttribute([MyFromUriAttribute] ComplexType value, ComplexType bodyValue)
{
}
public void GetFromHeaderAttribute([FromHeaderAttribute] string value)
{
}
public class ComplexType
{
public int Id { get; set; }
public string Name { get; set; }
}
private class MyFromUriAttribute : ModelBinderAttribute, IUriValueProviderFactory
{
public override IEnumerable<ValueProviderFactory> GetValueProviderFactories(HttpConfiguration configuration)
{
var factories = from f in base.GetValueProviderFactories(configuration) where f is IUriValueProviderFactory select f;
return factories;
}
}
private class FromHeaderAttribute : ModelBinderAttribute
{
public override IEnumerable<ValueProviderFactory> GetValueProviderFactories(HttpConfiguration configuration)
{
var factories = new ValueProviderFactory[] { new HeaderValueProvider() };
return factories;
}
}
private class HeaderValueProvider : ValueProviderFactory
{
public override IValueProvider GetValueProvider(Controllers.HttpActionContext actionContext)
{
throw new NotImplementedException();
}
}
}
}