Step 6. Add the scope in the “Startup” file. Register “ILogRepository” and “LogRepository.”
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddDbContext<DemoDbContext>(
option => option.UseSqlServer(Configuration.GetConnectionString("DB_EntityString")));
services.AddScoped(typeof(IEnterprise_MVC_CoreRepository), typeof(Enterprise_MVC_Repository));
services.AddScoped(typeof(ILogRepository), typeof(LogRepository));
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
} Step 7. Add the Logfile physical path in the “Startup” file.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
var path = Directory.GetCurrentDirectory();
loggerFactory.AddFile($"{path}\\Logs\\Log.txt");
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
} Step 8. Setting the program.cs file about the AOP.
Template method – It means the program defines an algorithm skeleton in the superclass, which lets subclasses…
Strategy – It allows the programs to define a family of an algorithm, put each…
State – This pattern can let the program’s object alter its behavior when its internal state changes,…
Observer – It lets the programs define a subscription mechanism to notify multiple objects, which means when…
Null Object – Designed to act as a default value of an object. From Design Pattern –…
Memento – It allows the programs to save and restore the object’s previous state without revealing its…
View Comments