This file contains 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 static class HttpActionResultExtentions | |
{ | |
public static IHttpActionResult AddHeader(this IHttpActionResult result, string name, IEnumerable<string> values) | |
=> new HeaderActionResult(result, name, values); | |
private class HeaderActionResult : IHttpActionResult | |
{ | |
private readonly IHttpActionResult actionResult; | |
private readonly Tuple<string, IEnumerable<string>> header; |
This file contains 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 static class IQueryableMockExtensions | |
{ | |
public static void SetUp<T>(this T self, IQueryable queryable) where T : IQueryable | |
{ | |
self.GetEnumerator().Returns(queryable.GetEnumerator()); | |
self.ElementType.Returns(queryable.ElementType); | |
self.Expression.Returns(queryable.Expression); |
This file contains 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
using Microsoft.AspNetCore.Authorization; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Extensions.Logging; | |
using Microsoft.Extensions.Options; | |
using Newtonsoft.Json; | |
using System; | |
using System.IdentityModel.Tokens.Jwt; | |
using System.Security.Claims; | |
using System.Security.Principal; | |
using System.Threading.Tasks; |
This file contains 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
using System.Collections.Generic; | |
using System.Web.Http; | |
using System.Web.Http.Controllers; | |
using System.Web.Http.Filters; | |
using Microsoft.Practices.Unity; | |
using Monads.NET; | |
namespace Infrastructure | |
{ | |
public class UnityFilterProvider : IFilterProvider |
This file contains 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 static class PropertyConfigurationExtensions | |
{ | |
public static PrimitivePropertyConfiguration IsUnique(this PrimitivePropertyConfiguration configuration, | |
string indexName, int indexOrder) | |
{ | |
var indexAttribute = new IndexAttribute(indexName, indexOrder) | |
{ | |
IsUnique = true | |
}; |
This file contains 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 class ModelValidationAttribute : ActionFilterAttribute | |
{ | |
public override void OnActionExecuting(HttpActionContext actionContext) | |
{ | |
var arguments = actionContext.ActionArguments; | |
var request = actionContext.Request; | |
if (HasNullArgument(arguments)) | |
{ |
This file contains 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 static class Functional | |
{ | |
public static TResult Do<T, TResult>(this T self, System.Func<T, TResult> func) => func(self); | |
} |
This file contains 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 class LowerCasePropertyNamesContractResolver : DefaultContractResolver | |
{ | |
protected override string ResolvePropertyName(string propertyName) => propertyName.ToLowerInvariant(); | |
} |
This file contains 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 static class ModelValidation | |
{ | |
public static IEnumerable<ValidationResult> ValidateModel<T>() | |
where T : class, new() => ValidateModel(default(T)); | |
public static IEnumerable<ValidationResult> ValidateModel<T>(T model) where T : class, new() | |
{ | |
model = model ?? new T(); | |
var validationContext = new ValidationContext(model); |
This file contains 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 static class HttpRequestMessageHelpers | |
{ | |
private const char separator = '/'; | |
public static string GetRootPath(this HttpRequestMessage message) | |
=> GetHostPath(message) + separator + GetVirtualPath(message); | |
private static string GetHostPath(HttpRequestMessage message) | |
=> message.RequestUri.GetLeftPart(UriPartial.Authority).TrimEnd(separator); |
NewerOlder