Beispiel #1
0
        public bool TryAddScoped <TService>() where TService : class
        {
            var serviceName = $"{typeof(TService)}";

            if (!Scoped.Contains(serviceName))
            {
                Scoped.Add(serviceName);
                ServiceCollection.TryAddScoped <TService>();
                return(true);
            }
            return(false);
        }
Beispiel #2
0
        public bool TryAddScoped <TService, TImplementation>(TService tservice, TImplementation tImplementation) where TService : Type where TImplementation : Type
        {
            var serviceName = $"{tservice}{tImplementation}";

            if (!Scoped.Contains(serviceName))
            {
                Scoped.Add(serviceName);
                ServiceCollection.TryAddScoped(tservice, tImplementation);
                return(true);
            }

            return(false);
        }
Beispiel #3
0
        public bool TryAddScoped <TService, TImplementation>() where TService : class where TImplementation : class, TService
        {
            var serviceName = $"{typeof(TService)}{typeof(TImplementation)}";

            if (!Scoped.Contains(serviceName))
            {
                Scoped.Add(serviceName);
                ServiceCollection.TryAddScoped <TService, TImplementation>();
                return(true);
            }

            return(false);
        }