This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Base route | |
| config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", new { id = RouteParameter.Optional }); | |
| // Nested route (must be distinguishable by param names from above) - Deisgnated by leading _ | |
| config.Routes.MapHttpRoute("NestedRoute", "_/{controller}/{rootId}"); | |
| // Root controller signature: | |
| public class AppDataController : ApiController | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var timer = new Stopwatch(); | |
| timer.Start(); | |
| var configuration = GlobalConfiguration.Configuration; | |
| var explorer = new ApiExplorer(configuration); | |
| var descriptions = explorer.ApiDescriptions; | |
| var controllerDescriptors = descriptions.Select(o => o.ActionDescriptor.ControllerDescriptor).Distinct().ToList(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| config.MessageHandlers.Add(new CachingHandler | |
| { | |
| UriTrimmer = (uri) => uri.LocalPath, | |
| LinkedRoutePatternProvider = LinkedRoutePatternProvider | |
| }); | |
| public static IEnumerable<string> LinkedRoutePatternProvider(string s, HttpMethod httpMethod) | |
| { | |
| var appAware = new Regex("/Api/[0-9]+/([a-z]|[A-Z])+/[0-9]+"); | |
| if (appAware.IsMatch(s)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public Dictionary<string, Tuple<object, object>> GetChanges(TEntityType original) | |
| { | |
| if (original == null) | |
| { | |
| throw new ArgumentNullException("original"); | |
| } | |
| if (!_entityType.IsAssignableFrom(original.GetType())) | |
| { | |
| throw new InvalidOperationException(string.Format("Entity mismatch exception between {0} and {1}", _entityType, original.GetType())); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); | |
| builder.EntitySet<EfContext>("EfContext"); | |
| IEdmModel model = builder.GetEdmModel(); | |
| var odataFormatters = ODataMediaTypeFormatters.Create(model); | |
| var delta = content.ReadAsAsync(type, odataFormatters).Result; |
NewerOlder