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
services.AddWebOptimizer(x => | |
{ | |
x.AddBundle("/css/site.css", "text/css;charset=UTF-8", "static/css/styles.css") | |
.UnCss() | |
.MinifyCss() | |
.AutoPrefixCss() | |
.Concatenate() | |
.FingerprintUrls(); | |
}); |
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
-- Outermost query for the final projection of the calculated values | |
SELECT | |
ProjectId, -- Primary key of the project | |
ProjectName, -- Name of the project | |
ProjectArchived, -- Whether the project is archived | |
ProjectQuotedDayRate, -- Daily rate quoted for the client | |
ProjectBaseDayRate, -- Estimated day rate for the project (cost to the company) | |
ProjectTotalBudget, -- Total budget (amount billed to the client) of the project | |
CurrencyCode, -- Currency code (presently only 'GDP') | |
ClientId, -- Primary key of the client |
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
#addin nuget:?package=Newtonsoft.Json&version=12.0.1 | |
using Newtonsoft.Json; | |
public class EfMigration | |
{ | |
public string Id { get; set; } | |
public string Name { get; set; } | |
public string SafeName { get; set; } | |
} |
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 PageRouteConstraint : IRouteConstraint | |
{ | |
private static readonly Regex regex = new Regex($"^page=(\\d+)$"); | |
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) | |
{ | |
if (routeDirection != RouteDirection.IncomingRequest || !values.TryGetValue(routeKey, out var page)) | |
{ | |
return false; | |
} |
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 abstract class AbstractAsyncInitializationMiddleware | |
{ | |
private readonly RequestDelegate next; | |
private readonly ILogger logger; | |
private Task initializationTask; | |
// ReSharper disable AccessToModifiedClosure | |
protected AbstractAsyncInitializationMiddleware(RequestDelegate next, IApplicationLifetime lifetime, ILogger logger) | |
{ | |
this.next = next; |
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 async Task<Model> Handle(Request request, CancellationToken cancellationToken) | |
{ | |
var query = context.Tickets.AsNoTracking().AsQueryable(); | |
query = FilterQuery(query, request); | |
var total = await query.CountAsync(cancellationToken); | |
query = OrderQuery(query, request); | |
query = PageQuery(query, request); |
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 MySigninManager : SignInManager<IdentityUser> | |
{ | |
public MySigninManager(UserManager<IdentityUser> userManager, IHttpContextAccessor contextAccessor, | |
IUserClaimsPrincipalFactory<IdentityUser> claimsFactory, IOptions<IdentityOptions> optionsAccessor, | |
ILogger<SignInManager<IdentityUser>> logger, IAuthenticationSchemeProvider schemes) | |
: base(userManager, contextAccessor, claimsFactory, optionsAccessor, logger, schemes) | |
{ | |
} | |
protected override async Task<SignInResult> SignInOrTwoFactorAsync(IdentityUser user, bool isPersistent, string loginProvider = null, bool bypassTwoFactor = false) |
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 ImplementationGenerator | |
{ | |
private const string AddServiceFormat = "services.AddScoped<{0},{1}>();"; | |
public string GenerateInterfaceImplementationRegistrations(IEnumerable<Assembly> assemblies) | |
{ | |
var types = assemblies.SelectMany(x => x.GetExportedTypes()) | |
.Where(x => x.GetInterfaces().Any()) | |
.Where(x => !x.IsAbstract && !x.IsInterface) | |
.Where(x => x.Namespace.EndsWith(".Impl")); |
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 CreateOrUpdateOperation : MigrationOperation | |
{ | |
public EntityWithName Entity { get; } | |
public Type EntityType { get; } | |
public CreateOrUpdateOperation(EntityWithName entity, Type entityType) | |
{ | |
Entity = entity; | |
EntityType = entityType; | |
} |
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 FilterFieldExpressionFactory | |
{ | |
public static Expression<Func<T, bool>> Create<T>(IEnumerable<FieldResult> filterFields) where T : class => | |
FilterExpressionFactory<T>.Create(filterFields); | |
private static class FilterExpressionFactory<T> where T : class | |
{ | |
private static Expression<Func<T, bool>> CreateFieldValue(FieldResult field, FieldValue fieldValue, ExpressionStarter<T> fieldPredicate) => | |
field.CriteriaType == CriteriaType.Is | |
? CriteriaIs(field, fieldValue, fieldPredicate) |
NewerOlder