Exemple #1
0
 public IActionResult Index()
 {
     ViewBag.Transistion1 = $"First transision instance {_transisionService1.GetGuid().ToString()}";
     ViewBag.Transistion2 = $"Second transision instance {_transisionService2.GetGuid().ToString()}";
     ViewBag.Scope1       = $"First Scoped instance {_scopedService1.GetGuid().ToString()}";
     ViewBag.Scope2       = $"Second transision instance {_scopedService2.GetGuid().ToString()}";
     ViewBag.Singleton1   = $"First Singleton instance {_singletonService1.GetGuid().ToString()}";
     ViewBag.Singleton2   = $"Second Singleton instance {_singletonService2.GetGuid().ToString()}";
     return(View());
 }
Exemple #2
0
        public IActionResult Get()
        {
            var scopedGuid    = (HttpContext.RequestServices.GetService(typeof(IScopedService)) as IScopedService).GetGuid();
            var transientGuid = (HttpContext.RequestServices.GetService(typeof(ITransientService)) as ITransientService).GetGuid();
            var singletonGuid = (HttpContext.RequestServices.GetService(typeof(ISingletonService)) as ISingletonService).GetGuid();

            var model = new List <IOCServiceResult>()
            {
                new IOCServiceResult("Scoped", _scopedService.GetGuid().ToString(), scopedGuid.ToString()),
                new IOCServiceResult("Transient", _transientService.GetGuid().ToString(), transientGuid.ToString()),
                new IOCServiceResult("Singleton", _singletonService.GetGuid().ToString(), singletonGuid.ToString()),
            };

            return(View("~/Views/Index.cshtml", model));
        }
Exemple #3
0
 public List <string> Scoped()
 {
     return(new List <string> {
         _scoped1.GetGuid(), _scoped2.GetGuid()
     });
 }
 public IActionResult Scoped()
 {
     return(View("Scoped", _scopedService.GetGuid()));
 }