Instantly share code, notes, and snippets.

Wullems Bart wullemsb

View GitHub Profile
View IOptionsSnapshot.cs
public IndexModel(IOptionsSnapshot<MyOptions> snapshotOptionsAccessor)
{
_snapshotOptions = snapshotOptionsAccessor.Value;
}
View IOptionsMonitor.cs
public IndexModel(IOptionsMonitor<MyOptions> optionsAccessor)
{
_options = optionsAccessor.CurrentValue;
}
View AsyncLogger.cs
Log.Logger = new LoggerConfiguration()
.WriteTo.Async(w => w.Console())
.CreateLogger();
View ValidateScopes.cs
WebHost
.CreateDefaultBuilder(args)
.UseDefaultServiceProvider((context, options) => {options.ValidateScopes = true;});
View tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"importHelpers": true,
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
View RootQuery.cs
public class RootQuery : ObjectGraphType
{
public RootQuery()
{
Name = "Query";
Field<NonNullGraphType<ProductsQuery>>().Name("Products").Resolve(context => new { });
Field<NonNullGraphType<CustomersQuery>>().Name("Customers").Resolve(context => new { });
}
}
View waitfor
PUT myindex/_doc/1?refresh=wait_for
{
"productname":"Xbox One"
"color": "black"
}
View karma.conf.js
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
View web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- To customize the asp.net core module uncomment and edit the following section.
For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
<system.webServer>
<handlers>
<remove name="aspNetCore" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
View SampleContext.cs
public class SampleContext:DbContext
{
public SampleContext()
{
}
public SampleContext(string connectionString)
{
_connectionString = connectionString;