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 interface IDispatcher | |
{ | |
Task<TResult> Dispatch<TQuery, TResult>(TQuery operation, CancellationToken cancellation = default) where TQuery : IOperation<TResult>; | |
Task Publish<TNotification>(TNotification notification, CancellationToken cancellation = default) where TNotification : INotification; | |
} | |
public class Dispatcher(IServiceProvider serviceProvider) : IDispatcher | |
{ | |
public Task<TResult> Dispatch<TOperation, TResult>(TOperation operation, CancellationToken cancellation = default) where TOperation : IOperation<TResult> |
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
@if (_data != null) | |
{ | |
var dates = _data.Select(x => x.Date).Distinct(); | |
<table> | |
<tr> | |
@foreach (var date in dates) | |
{ | |
<th>@date.ToShortDateString()</th> |
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
@if (_data != null) | |
{ | |
var dates = _data.Select(x => x.Date).Distinct(); | |
<table> | |
<tr> | |
@foreach (var date in dates) | |
{ | |
<th>@date.ToShortDateString()</th> | |
} |
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
var builder = WebApplication.CreateBuilder(args); | |
builder.Host.UseWolverine(); | |
builder.Services.AddHttpContextAccessor(); | |
var app = builder.Build(); | |
app.MapWolverineEndpoints(); |
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
[TestClass] | |
public class WolverineTests | |
{ | |
[TestMethod] | |
public async Task cascade_test() | |
{ | |
using var host = await Host.CreateDefaultBuilder() | |
.UseWolverine((context, opts) => { }) | |
.StartAsync(); |
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
builder.Services.Configure<JwtBearerOptions>(options => | |
{ | |
options.Events.OnChallenge += OnChallenge; | |
}); | |
builder.Services.AddAuthentication().AddMicrosoftIdentityWebApi(builder.Configuration); | |
async Task OnChallenge(JwtBearerChallengeContext context) | |
{ |
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 override async Task<Account> CreateAsync (Account entity, CancellationToken token) | |
{ | |
var context = new Context(); | |
entity.CreateDate = DateTime.Now; | |
entity.LastUpdated = DateTime.Now; | |
if (entity.ParentId == 0) entity.ParentId = 1; | |
context.Accounts.Add(entity); | |
await context.SaveChangesAsync(); | |
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 dynamic CheckLoginCredentials(string UserName, string Password) | |
{ | |
return context.Agents | |
.Where(x => x.LoginName == UserName && x.LoginPassword == Password) | |
.Select(x => new { | |
x.LoginName, | |
x.LoginPassword | |
}) | |
.FirstOrDefault(); | |
} |
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 BrianAssessment | |
{ | |
public void show_merged_array_ascending_linq() | |
{ | |
// arrange | |
var array1 = new[] {1, 3, 5, 8}; | |
var array2 = new[] {0, 3, 3, 6, 9}; | |
// act | |
var ordered = array1.Concat(array2).OrderBy(x => x); |
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 (var client = new HttpClient()) | |
{ | |
client.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0"); | |
var result = await client.GetStringAsync("http://api.db-ip.com/v2/free/1.10.16.5"); | |
} |
NewerOlder