public ConditionCopyNonLazyBinder FromInstance(object instance) { BindingUtil.AssertInstanceDerivesFromOrEqual(instance, AllParentTypes); ProviderFunc = (container) => new InstanceProvider(ContractType, instance, container); return(this); }
public ConditionBinder FromInstance(object instance) { BindingUtil.AssertInstanceDerivesFromOrEqual(instance, AllParentTypes); SubFinalizer = CreateFinalizer( (container) => new InstanceProvider(container, ContractType, instance)); return(this); }
protected ScopeBinder FromInstanceBase(object instance) { BindingUtil.AssertInstanceDerivesFromOrEqual(instance, AllParentTypes); SubFinalizer = new ScopableBindingFinalizer( BindInfo, SingletonTypes.ToInstance, instance, (_, type) => new InstanceProvider(type, instance)); return(new ScopeBinder(BindInfo)); }
protected ScopeConditionCopyNonLazyBinder FromInstanceBase(object instance) { BindingUtil.AssertInstanceDerivesFromOrEqual(instance, AllParentTypes); BindInfo.RequireExplicitScope = false; SubFinalizer = new ScopableBindingFinalizer( BindInfo, SingletonTypes.FromInstance, instance, (container, type) => new InstanceProvider(type, instance, container)); return(new ScopeConditionCopyNonLazyBinder(BindInfo)); }
protected ScopeConcreteIdArgConditionCopyNonLazyBinder FromInstanceBase(object instance) { BindingUtil.AssertInstanceDerivesFromOrEqual(instance, AllParentTypes); BindInfo.RequireExplicitScope = false; // Don't know how it's created so can't assume here that it violates AsSingle BindInfo.MarkAsCreationBinding = false; SubFinalizer = new ScopableBindingFinalizer( BindInfo, (container, type) => new InstanceProvider(type, instance, container)); return(new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo)); }
protected ScopeBinder FromInstanceBase(object instance, bool allowNull) { if (!allowNull) { Assert.That(!ZenUtilInternal.IsNull(instance), "Found null instance for type '{0}' in FromInstance method", ConcreteTypes.First().Name()); } BindingUtil.AssertInstanceDerivesFromOrEqual(instance, AllParentTypes); SubFinalizer = new ScopableBindingFinalizer( BindInfo, SingletonTypes.ToInstance, instance, (container, type) => new InstanceProvider(container, type, instance)); return(new ScopeBinder(BindInfo)); }