Ejemplo n.º 1
0
        /// <summary>
        /// Adds a named service to the dependency map.
        /// </summary>
        /// <remarks>This service will be created once per web session.</remarks>
        /// <param name="map">The target dependency map.</param>
        /// <param name="serviceName">The service name.</param>
        /// <param name="serviceType">The service type.</param>
        /// <param name="implementingType">The implementing type.</param>
        public static void AddPerSessionService(this DependencyMap map, string serviceName, Type serviceType, Type implementingType)
        {
            // Add the SessionCache by default
            if (!map.Contains(typeof(ICache)))
                map.AddService<ICache, SessionCache>();

            // The cached instantiation class will use the cache in the container
            // to cache service instances
            var dependency = new Dependency(serviceType, serviceName);
            var implementation = new CachedInstantiation(new TransientType(implementingType, map, new ConstructorResolver()));

            map.AddService(dependency, implementation);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a named service to the dependency map.
        /// </summary>
        /// <remarks>This service will be created once per web session.</remarks>
        /// <param name="map">The target dependency map.</param>
        /// <param name="serviceName">The service name.</param>
        /// <param name="serviceType">The service type.</param>
        /// <param name="implementingType">The implementing type.</param>
        public static void AddPerSessionService(this DependencyMap map, string serviceName, Type serviceType, Type implementingType)
        {
            // Add the SessionCache by default
            if (!map.Contains(typeof(ICache)))
            {
                map.AddService <ICache, SessionCache>();
            }

            // The cached instantiation class will use the cache in the container
            // to cache service instances
            var dependency     = new Dependency(serviceType, serviceName);
            var implementation = new CachedInstantiation(new TransientType(implementingType, map, new ConstructorResolver()));

            map.AddService(dependency, implementation);
        }