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 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
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 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 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 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 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); |
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
string GetRegularExpressionAttributePattern<T>(string property) | |
{ | |
return typeof(T) | |
.GetProperty(property) | |
.GetCustomAttribute<RegularExpressionAttribute>() | |
.Pattern; | |
} |
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
int GetStringLengthAttributeValue<T>(string property) | |
{ | |
return typeof(T) | |
.GetProperty(property) | |
.GetCustomAttribute<StringLengthAttribute>() | |
.MaximumLength; | |
} |
NewerOlder