SmartDIContainer.cs
/// <summary>
/// Adds a list of bound instances to a single shared instance.
/// </summary>
/// <param name="sharedInstance">The shared instance.</param>
/// <param name="sharedInstanceType">
/// The type of the object. The shared instance is often just an object without a final
/// type.
/// </param>
/// <param name="boundParents">The bound member. Each of these are a different "parent" to the same shared instance.</param>
Adds a list of bound instances to a single shared instance.
Adds a list of bound instances to a single shared instance .
protected void CreateSharedInstances
      (
         object          sharedInstance,
         Type            sharedInstanceType,
         params object[] boundParents
      )
      {
         if (!_sharedInstancesWithBoundMembers.ContainsKey(sharedInstance))
         {
            _sharedInstancesWithBoundMembers.Add(sharedInstance, new List<object>(boundParents));
         }
         else
         {
            var boundInstances = _sharedInstancesWithBoundMembers[sharedInstance];
            foreach (var parent in boundParents)
            {
               if (boundInstances.All(bi => !ReferenceEquals(bi, parent)))
               {
                  boundInstances.Add(parent);
               }
            }
         }
      }
protected void CreateSharedInstances ( object sharedInstance , Type sharedInstanceType , params object [ ] boundParents ) { if ( ! _sharedInstancesWithBoundMembers . ContainsKey ( sharedInstance ) ) { _sharedInstancesWithBoundMembers . Add ( sharedInstance , new List < object > ( boundParents ) ) ; } else { var boundInstances = _sharedInstancesWithBoundMembers [ sharedInstance ] ; foreach ( var parent in boundParents ) { if ( boundInstances . All ( bi => ! ReferenceEquals ( bi , parent ) ) ) { boundInstances . Add ( parent ) ; } } } }
Adds a list of bound instances to a single shared instance.
Adds a list of bound instances to a single shared instance .
sharedInstance
object
The shared instance.
The shared instance .
sharedInstanceType
Type
The type of the object. The shared instance is often just an object without a final
type.
The type of the object . The shared instance is often just an object without a final type .
boundParents
The bound member. Each of these are a different "parent" to the same shared instance.
The bound member . Each of these are a different " parent " to the same shared instance .