diff --git a/ServiceScope/Controllers/HomeController.cs b/ServiceScope/Controllers/HomeController.cs index b3b8c29..34c2e85 100644 --- a/ServiceScope/Controllers/HomeController.cs +++ b/ServiceScope/Controllers/HomeController.cs @@ -5,9 +5,9 @@ namespace ServiceScope.Controllers { public class HomeController : Controller { - private ISingletonService _singleton; - private IScopedService _scoped; - private ITransientService _transient; + private readonly ISingletonService _singleton; + private readonly IScopedService _scoped; + private readonly ITransientService _transient; public HomeController( ISingletonService singleton, @@ -19,9 +19,10 @@ public HomeController( _transient = transient; } - public IActionResult Index() + [Route("/")] + public IActionResult Singleton() { - return View("Index", _singleton.GetGuid()); + return View("Singleton", _singleton.GetGuid()); } public IActionResult Scoped() diff --git a/ServiceScope/Program.cs b/ServiceScope/Program.cs index ae7281f..eaaebc3 100644 --- a/ServiceScope/Program.cs +++ b/ServiceScope/Program.cs @@ -1,12 +1,5 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore; +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; namespace ServiceScope { diff --git a/ServiceScope/Services/ScopedService.cs b/ServiceScope/Services/ScopedService.cs index 2c8e9b3..1eecc69 100644 --- a/ServiceScope/Services/ScopedService.cs +++ b/ServiceScope/Services/ScopedService.cs @@ -6,7 +6,7 @@ public interface IScopedService : IService { } public class ScopedService : IScopedService { - private string _guid; + private readonly string _guid; public ScopedService() { diff --git a/ServiceScope/Services/SingletonService.cs b/ServiceScope/Services/SingletonService.cs index d444eef..17ce4d6 100644 --- a/ServiceScope/Services/SingletonService.cs +++ b/ServiceScope/Services/SingletonService.cs @@ -6,7 +6,7 @@ public interface ISingletonService : IService { } public class SingletonService : ISingletonService { - private string _guid; + private readonly string _guid; public SingletonService() { diff --git a/ServiceScope/Services/TransientService.cs b/ServiceScope/Services/TransientService.cs index 4a6e392..d2597ba 100644 --- a/ServiceScope/Services/TransientService.cs +++ b/ServiceScope/Services/TransientService.cs @@ -6,7 +6,7 @@ public interface ITransientService : IService { } public class TransientService : ITransientService { - private string _guid; + private readonly string _guid; public TransientService() { diff --git a/ServiceScope/Views/Home/Scoped.cshtml b/ServiceScope/Views/Home/Scoped.cshtml index f868551..b597fc5 100644 --- a/ServiceScope/Views/Home/Scoped.cshtml +++ b/ServiceScope/Views/Home/Scoped.cshtml @@ -1,13 +1,21 @@ @model string -
@Model
+ - Useful for? -
- -@Model
+ @Model
+ - Useful for? -
-@Scoped.GetGuid()
+ @Singleton.GetGuid()
+ @Transient.GetGuid()
+