public DiCachedRootBinding(IDiRootBinding binding, DiRootBindingType rootBindingType) { if (binding == null) { throw new ArgumentNullException(nameof(binding)); } this.binding = binding; this.rootBindingType = rootBindingType; }
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); }
private object InternalInstantiate(Type type, DiRootBindingType rootBindingType) => GetOrAddCachedBinding(type, rootBindingType).Instantiate(this);
private IDiCachedRootBinding GetOrAddCachedBinding(Type type, DiRootBindingType rootBindingType) { return(cachedBindings.GetOrAdd(type, t => new DiCachedRootBinding(new DiRootBinding(t), rootBindingType))); }
private object InternalGet(Type type, DiRootBindingType rootBindingType) => GetOrAddCachedBinding(type, rootBindingType).GetResult(this);
public IDiRootBinding GetRootBinding(Type type, DiRootBindingType rootBindingType) => GetOrAddCachedBinding(type, rootBindingType).GetRootBinding(rootBindingType);
private DiFluentBinderCommon <object> InternalBind(Type type, DiRootBindingType rootBindingType) => new DiFluentBinderCommon <object>(this, GetRootBinding(type, rootBindingType));
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>()); }