예제 #1
0
       public GreetingController(MySingletonService s, MyTransientService t1, MyTransientService t2, MyScopedService sc1, MyScopedService sc2)
       {
           Console.WriteLine($@"Got
 Singleton: {s.GetHashCode()}
 Transient 1: {t1.GetHashCode()}
 Transient 2: {t2.GetHashCode()}
 Scoped 1: {sc1.GetHashCode()}
 Scoped 2: {sc2.GetHashCode()}");
       }
예제 #2
0
        public Task Invoke(HttpContext context, MySingletonService s, MyTransientService t1, MyTransientService t2, MyScopedService sc1, MyScopedService sc2)
        {
            Console.WriteLine($@"Custom middleware got
  Singleton: {s.GetHashCode()}
  Transient 1: {t1.GetHashCode()}
  Transient 2: {t2.GetHashCode()}
  Scoped 1: {sc1.GetHashCode()}
  Scoped 2: {sc2.GetHashCode()}");

            // Call the next delegate/middleware in the pipeline
            return(this._next(context));
        }