public StorageFile(Zongsoft.Services.IServiceProvider serviceProvider) { if (serviceProvider != null) { _storage = serviceProvider.Resolve <Zongsoft.Runtime.Caching.ICache>(); } }
public StorageBucket(Zongsoft.Runtime.Caching.ICache storage) { if(storage == null) throw new ArgumentNullException("storage"); _storage = storage; }
public StorageFile(Zongsoft.Services.IServiceProvider serviceProvider) { if(serviceProvider != null) { _storage = serviceProvider.Resolve<Zongsoft.Runtime.Caching.ICache>(); } }
public StorageBucket(Zongsoft.Runtime.Caching.ICache storage) { if (storage == null) { throw new ArgumentNullException("storage"); } _storage = storage; }
public void ResolveTest() { Zongsoft.Runtime.Caching.ICache cache = null; cache = _provider1.Resolve <Zongsoft.Runtime.Caching.ICache>(); Assert.NotNull(cache); Assert.Equal("MemoryCache-1", cache.Name); cache = _provider1.Resolve("MC1") as Zongsoft.Runtime.Caching.ICache; Assert.NotNull(cache); Assert.Equal("MemoryCache-1", cache.Name); cache = _provider1.Resolve("MC2") as Zongsoft.Runtime.Caching.ICache; Assert.Null(cache); Assert.NotNull(_provider1.Resolve("string")); Assert.IsAssignableFrom <string>(_provider1.Resolve("string")); Assert.NotNull(_provider2.Resolve <string>()); Assert.NotNull(_provider3.Resolve <string>()); Assert.IsAssignableFrom <string>(_provider3.Resolve("string")); //将二号服务容器加入到一号服务容器中 _provider1.Register(_provider2); cache = _provider1.Resolve("MC2") as Zongsoft.Runtime.Caching.ICache; Assert.NotNull(cache); Assert.Equal("MemoryCache-2", cache.Name); cache = _provider1.Resolve("MC3") as Zongsoft.Runtime.Caching.ICache; Assert.Null(cache); //将三号服务容器加入到二号服务容器中 _provider2.Register(_provider3); //将一号服务容器加入到三号服务容器中(形成循环链) _provider3.Register(_provider1); cache = _provider1.Resolve("MC3") as Zongsoft.Runtime.Caching.ICache; Assert.NotNull(cache); Assert.Equal("MemoryCache-3", cache.Name); var address = _provider1.Resolve <Zongsoft.Tests.Address>(); Assert.NotNull(address); var department = _provider1.Resolve <Zongsoft.Tests.Department>(); Assert.NotNull(department); var person = _provider1.Resolve <Zongsoft.Tests.Person>(); Assert.NotNull(person); Assert.NotNull(_provider1.Resolve("string")); Assert.IsAssignableFrom <string>(_provider1.Resolve("string")); Assert.NotNull(_provider2.Resolve <string>()); Assert.NotNull(_provider3.Resolve <string>()); Assert.IsAssignableFrom <string>(_provider3.Resolve("string")); //测试不存在的服务 Assert.Null(_provider1.Resolve <IWorker>()); Assert.Null(_provider1.Resolve("NoExisted")); }