Skip to content

Instantly share code, notes, and snippets.

Wullems Bart wullemsb

View GitHub Profile
View PointAutoProperties.cs
public readonly struct Point
{
public double X { get; }
public double Y { get; }
public Point(double x, double y) => (X, Y) = (x, y);
public override string ToString() => $"({X}, {Y})";
}
View Point.cs
public readonly struct Point
{
public readonly double X;
public readonly double Y;
public Point(double x, double y) => (X, Y) = (x, y);
public override string ToString() => $"({X}, {Y})";
}
View StartupGraphQL.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseWebSockets();
app.UseGraphQLWebSocket<OrdersSchema>(new GraphQLWebSocketsOptions());
View SchemaMiddleware.cs
public class SchemaMiddleware
{
private readonly RequestDelegate _next;
public SchemaMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task Invoke(HttpContext context, OrdersSchema schema)
View PIIVisible.cs
IdentityModelEventSource.ShowPII = true;
View MyCustomStartup.cs
namespace ClassLibrary1
{
public class MyCustomStartup : IHostingStartup
{
public void Configure(IWebHostBuilder builder)
{
Console.WriteLine("Calling my custom startup");
}
}
}
View AddCorsFixed.cs
services.AddCors(action =>
action.AddPolicy(policyName, builder =>
builder
.AllowAnyMethod()
.AllowAnyHeader()
.WithOrigins("https://my.example.com")
.AllowCredentials()));
View AddCors.cs
services.AddCors(action =>
action.AddPolicy(policyName, builder =>
builder
.AllowAnyMethod()
.AllowAnyHeader()
.AllowAnyOrigin()
.AllowCredentials()));
View TestConfigSetup.cs
[TestFixture]
public class Tests
{
private IConfiguration _configuration;
[OneTimeSetUp]
public void Init()
{
_configuration=BuildConfiguration(TestContext.CurrentContext.TestDirectory);
}
View BuildConfig.cs
public IConfigurationRoot BuildConfiguration(string testDirectory)
{
return new ConfigurationBuilder()
.SetBasePath(testDirectory)
.AddJsonFile("appsettings.json", optional: true)
.Build();
}
You can’t perform that action at this time.