예제 #1
0
        /// <summary>
        /// Merges two dependency maps into a single dependency map.
        /// </summary>
        /// <param name="left">The left-hand dependency map.</param>
        /// <param name="right">The right-hand dependency map.</param>
        /// <returns>A combined dependency map.</returns>
        public static DependencyMap operator +(DependencyMap left, DependencyMap right)
        {
            var leftEntries  = left._entries;
            var rightEntries = right._entries;

            // Merge the two entries into a single entry
            var combinedEntries = new HashList <IDependency, IImplementation>();

            foreach (var key in leftEntries.Keys)
            {
                combinedEntries.Add(key, leftEntries[key]);
            }

            foreach (var key in rightEntries.Keys)
            {
                combinedEntries.Add(key, rightEntries[key]);
            }

            var map = new DependencyMap();

            map._entries = combinedEntries;

            return(map);
        }
 /// <summary>
 /// Registers the generic service type as a singleton type.
 /// </summary>
 /// <param name="serviceType">The service type that will be registered.</param>
 /// <param name="concreteType">The generic concrete type that will implement the generic service type.</param>
 /// <param name="map">The dependency map that contains all the dependencies.</param>
 protected override void Register(Type serviceType, Type concreteType, DependencyMap map)
 {
     map.AddSingletonService(serviceType, concreteType);
 }
 /// <summary>
 /// Registers the generic service type.
 /// </summary>
 /// <param name="serviceType">The service type that will be registered.</param>
 /// <param name="concreteType">The generic concrete type that will implement the generic service type.</param>
 /// <param name="map">The dependency map that contains all the dependencies.</param>
 protected virtual void Register(Type serviceType, Type concreteType, DependencyMap map)
 {
     map.AddService(serviceType, concreteType);
 }