Exemplo n.º 1
0
        public static void AddTransient <Interface, Implementation>()
            where Interface : class
            where Implementation : class, Interface
        {
            var interfaceType      = typeof(Interface);
            var implementationType = typeof(Implementation);
            var serviceDeclaration = new ServiceDeclaration(interfaceType, implementationType);

            _transientDeclarations.AddOrUpdate(interfaceType, serviceDeclaration, (key, existingVal) => serviceDeclaration);
        }
Exemplo n.º 2
0
        private static ServiceDeclaration LocateServiceDeclaration(Type interfaceType)
        {
            ServiceDeclaration entry = null;

            if (_transientDeclarations.ContainsKey(interfaceType))
            {
                entry = _transientDeclarations[interfaceType];
            }
            else
            {
                entry = _singletonDeclarations[interfaceType];
            }

            return(entry);
        }