-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.IO; | ||
using System.Threading; | ||
using Autofac; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Logging; | ||
using OctaneEngineCore; | ||
using Serilog; | ||
using Serilog.Sinks.SystemConsole.Themes; | ||
|
||
namespace OctaneTester.Examples; | ||
|
||
public class Autofac | ||
{ | ||
public void AutofacExample() | ||
{ | ||
var seriLog = new LoggerConfiguration() | ||
.Enrich.FromLogContext() | ||
.MinimumLevel.Error() | ||
.WriteTo.Async(a => a.File("./OctaneLog.txt")) | ||
.WriteTo.Async(a => a.Console(theme: AnsiConsoleTheme.Sixteen)) | ||
.CreateLogger(); | ||
var factory = LoggerFactory.Create(logging => | ||
{ | ||
logging.AddSerilog(seriLog); | ||
}); | ||
|
||
var builder = new ConfigurationBuilder(); | ||
builder.SetBasePath(Directory.GetCurrentDirectory()) | ||
.AddJsonFile("appsettings.json", true, true); | ||
var configRoot = builder.Build(); | ||
|
||
var pauseTokenSource = new PauseTokenSource(); | ||
Check warning Code scanning / CodeQL Useless assignment to local variable Warning
This assignment to
pauseTokenSource Error loading related location Loading |
||
var cancelTokenSource = new CancellationTokenSource(); | ||
Check warning Code scanning / CodeQL Useless assignment to local variable Warning
This assignment to
cancelTokenSource Error loading related location Loading Check warning Code scanning / CodeQL Missing Dispose call on local IDisposable Warning
Disposable 'CancellationTokenSource' is created but not disposed.
|
||
|
||
var containerBuilder = new ContainerBuilder(); | ||
containerBuilder.RegisterInstance(factory).As<ILoggerFactory>(); | ||
containerBuilder.RegisterInstance(configRoot).As<IConfiguration>(); | ||
containerBuilder.AddOctane(); | ||
var engineContainer = containerBuilder.Build(); | ||
var engine = engineContainer.Resolve<IEngine>(); | ||
Check warning Code scanning / CodeQL Useless assignment to local variable Warning
This assignment to
engine Error loading related location Loading |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.IO; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Logging; | ||
using OctaneEngineCore; | ||
using Serilog; | ||
using Serilog.Sinks.SystemConsole.Themes; | ||
|
||
namespace OctaneTester.Examples; | ||
|
||
public class NoAutofac | ||
{ | ||
public void NoAutoFacExample() | ||
{ | ||
#region Logging Example | ||
var seriLog = new LoggerConfiguration() | ||
.Enrich.FromLogContext() | ||
.MinimumLevel.Error() | ||
.WriteTo.Async(a => a.File("./OctaneLog.txt")) | ||
.WriteTo.Async(a => a.Console(theme: AnsiConsoleTheme.Sixteen)) | ||
.CreateLogger(); | ||
var factory = LoggerFactory.Create(logging => | ||
{ | ||
logging.AddSerilog(seriLog); | ||
}); | ||
#endregion | ||
|
||
#region Configuration Loading | ||
var builder = new ConfigurationBuilder(); | ||
builder.SetBasePath(Directory.GetCurrentDirectory()) | ||
.AddJsonFile("appsettings.json", true, true); | ||
var configRoot = builder.Build(); | ||
#endregion | ||
|
||
EngineBuilder.Build(factory, configRoot); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.IO; | ||
using System.Threading; | ||
using Autofac; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Logging; | ||
using OctaneEngineCore; | ||
using Serilog; | ||
using Serilog.Sinks.SystemConsole.Themes; | ||
|
||
namespace OctaneTester.Examples; | ||
|
||
public class NoLogger | ||
{ | ||
public void NoLoggerExample() | ||
{ | ||
#region Configuration Loading | ||
var builder = new ConfigurationBuilder(); | ||
builder.SetBasePath(Directory.GetCurrentDirectory()) | ||
.AddJsonFile("appsettings.json", true, true); | ||
var configRoot = builder.Build(); | ||
#endregion | ||
|
||
var pauseTokenSource = new PauseTokenSource(); | ||
Check warning Code scanning / CodeQL Useless assignment to local variable Warning
This assignment to
pauseTokenSource Error loading related location Loading |
||
var cancelTokenSource = new CancellationTokenSource(); | ||
Check warning Code scanning / CodeQL Useless assignment to local variable Warning
This assignment to
cancelTokenSource Error loading related location Loading Check warning Code scanning / CodeQL Missing Dispose call on local IDisposable Warning
Disposable 'CancellationTokenSource' is created but not disposed.
|
||
|
||
var containerBuilder = new ContainerBuilder(); | ||
containerBuilder.RegisterInstance(configRoot).As<IConfiguration>(); | ||
containerBuilder.AddOctane(); | ||
var engineContainer = containerBuilder.Build(); | ||
var engine = engineContainer.Resolve<IEngine>(); | ||
Check warning Code scanning / CodeQL Useless assignment to local variable Warning
This assignment to
engine Error loading related location Loading |
||
} | ||
} |