Exemple #1
0
 public DiCachedRootBinding(IDiRootBinding binding, DiRootBindingType rootBindingType)
 {
     if (binding == null)
     {
         throw new ArgumentNullException(nameof(binding));
     }
     this.binding         = binding;
     this.rootBindingType = rootBindingType;
 }
Exemple #2
0
        public IDiRootBinding GetRootBinding(DiRootBindingType requestedRootBindingType)
        {
            if (requestedRootBindingType != rootBindingType)
            {
                throw new InvalidOperationException($"Trying to use a '{rootBindingType}' binding as a '{requestedRootBindingType}' binding");
            }
            var bindingLoc = binding;

            if (bindingLoc == null)
            {
                throw new InvalidOperationException("Trying to bind after an instance had already been created.");
            }
            return(bindingLoc);
        }
Exemple #3
0
 private object InternalInstantiate(Type type, DiRootBindingType rootBindingType) =>
 GetOrAddCachedBinding(type, rootBindingType).Instantiate(this);
Exemple #4
0
 private IDiCachedRootBinding GetOrAddCachedBinding(Type type, DiRootBindingType rootBindingType)
 {
     return(cachedBindings.GetOrAdd(type, t => new DiCachedRootBinding(new DiRootBinding(t), rootBindingType)));
 }
Exemple #5
0
 private object InternalGet(Type type, DiRootBindingType rootBindingType) =>
 GetOrAddCachedBinding(type, rootBindingType).GetResult(this);
Exemple #6
0
 public IDiRootBinding GetRootBinding(Type type, DiRootBindingType rootBindingType) =>
 GetOrAddCachedBinding(type, rootBindingType).GetRootBinding(rootBindingType);
Exemple #7
0
 private DiFluentBinderCommon <object> InternalBind(Type type, DiRootBindingType rootBindingType) =>
 new DiFluentBinderCommon <object>(this, GetRootBinding(type, rootBindingType));
Exemple #8
0
 private DiFluentBinderCommon <T> InternalBind <T>(DiRootBindingType rootBindingType) =>
 new DiFluentBinderCommon <T>(this, GetRootBinding(typeof(T), rootBindingType));
 private IEnumerable <IDiRootBindingItem> GetGenericItems(IDiContainer di, DiRootBindingType rootBindingType)
 {
     return(abstractType.IsGenericType
         ? di.GetRootBinding(abstractType.GetGenericTypeDefinition(), rootBindingType).Items
         : Enumerable.Empty <IDiRootBindingItem>());
 }