本文整理汇总了C#中ICache类的典型用法代码示例。如果您正苦于以下问题:C# ICache类的具体用法?C# ICache怎么用?C# ICache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ICache类属于命名空间,在下文中一共展示了ICache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PreStartInitialise
public static void PreStartInitialise()
{
switch (WebConfigSettings.CacheProviderType)
{
#if !NET35
case CacheTypes.AppFabricCache:
_cache = new AppFabricCacheAdapter();
break;
#endif
case CacheTypes.MemoryCache:
default:
_cache = new MemoryCacheAdapter();
// http://msdn.microsoft.com/en-us/library/wcxyzt4d.aspx
//_cache = Activator.CreateInstance(Type.GetType(WebConfigSettings.CacheProviderType, _logger)) as ICache;
break;
}
_cacheProvider = new CacheProvider(_cache);
}
示例2: OpenDatabaseViewModel
public OpenDatabaseViewModel(
INavigationService navigationService,
IDatabaseInfoRepository databaseInfoRepository,
ICanSHA256Hash hasher,
IDialogService dialogService,
IPWDatabaseDataSource databaseSource,
ICache cache)
{
_cache = cache;
_databaseSource = databaseSource;
_dialogService = dialogService;
_databaseInfoRepository = databaseInfoRepository;
_hasher = hasher;
_navigationService = navigationService;
var canHitOpen = this.WhenAny(
vm => vm.Password,
vm => vm.KeyFileName,
(p, k) => !string.IsNullOrEmpty(p.Value) || !string.IsNullOrEmpty(k.Value));
OpenCommand = new ReactiveCommand(canHitOpen);
OpenCommand.Subscribe(OpenDatabase);
GetKeyFileCommand = new ReactiveCommand();
GetKeyFileCommand.Subscribe(GetKeyFile);
ClearKeyFileCommand = new ReactiveCommand();
ClearKeyFileCommand.Subscribe(ClearKeyFile);
IObservable<string> keyFileNameChanged = this.WhenAny(vm => vm.KeyFileName, kf => kf.Value);
keyFileNameChanged.Subscribe(v => ClearKeyFileButtonIsVisible = !string.IsNullOrWhiteSpace(v));
keyFileNameChanged.Subscribe(v => GetKeyFileButtonIsVisible = string.IsNullOrWhiteSpace(v));
}
示例3: BenchmarkRunner
public BenchmarkRunner(ICache cache, IBenchmark benchmark)
{
_cache = cache;
_benchmark = benchmark;
_singleMeasurer = new SingleThreadedBenchmarkMeasurer(cache, benchmark);
_multiMeasurer = new MultiThreadedBenchmarkMeasurer(cache, benchmark);
}
示例4: AuthorizationContextCache
public AuthorizationContextCache(ICache cache, IControllerContextCache controllerContextCache, IControllerDescriptorCache controllerDescriptorCache, IRouteDataCache routeDataCache)
{
this.cache = cache;
this.routeDataCache = routeDataCache;
this.controllerContextCache = controllerContextCache;
this.controllerDescriptorCache = controllerDescriptorCache;
}
示例5: CobreGratisForTests
public CobreGratisForTests(
string clientAppIdentification, string authToken, ILogger logger, ICache cache,
INetworkServices networkServices, IXmlSerializer xmlSerializer
)
: base(clientAppIdentification, authToken, logger, cache, networkServices, xmlSerializer)
{
}
示例6: RequestQueue
public RequestQueue(ICache cache, INetwork network, int threadPoolSize, IResponseDelivery delivery)
{
this.mCache = cache;
this.mNetwork = network;
this.mDispatchers = new NetworkDispatcher[threadPoolSize];
this.mDelivery = delivery;
}
示例7: RunCacheTests
private static void RunCacheTests(ICache cache)
{
cache.Insert("ByteArray", new byte[] {0, 1, 2, 3}, CachePriority.Normal);
cache.Insert("String", "Hello World", CachePriority.Normal);
cache.Insert("Object", new TestObject("Test Object", 1234), CachePriority.Normal);
var byteArray = cache.Lookup("ByteArray");
Assert.IsNotNull(byteArray);
Assert.AreEqual(4, byteArray.Length);
for (int i = 0; i < 4; i++) Assert.AreEqual(i, byteArray[i]);
var cachedString = cache.Lookup<string>("String");
Assert.IsNotNull(cachedString);
Assert.AreEqual("Hello World", cachedString);
var cachedObject = cache.Lookup<TestObject>("Object");
Assert.IsNotNull(cachedObject);
Assert.AreEqual("Test Object", cachedObject.StringValue);
Assert.AreEqual(1234, cachedObject.LongValue);
cache.Remove("Object");
Assert.IsNull(cache.Lookup("Object"));
Assert.IsFalse(cache.ContainsKey("Object"));
Assert.IsTrue(cache.ContainsKey("String"));
}
示例8: Element
protected Element(MSpecUnitTestProvider provider,
IPsi psiModuleManager,
ICache cacheManager,
Element parent,
ProjectModelElementEnvoy projectEnvoy,
IClrTypeName declaringTypeName,
bool isIgnored)
{
if (declaringTypeName == null)
{
throw new ArgumentNullException("declaringTypeName");
}
if (projectEnvoy != null)
{
this._projectEnvoy = projectEnvoy;
}
this._provider = provider;
this._declaringTypeName = declaringTypeName;
this._psiModuleManager = psiModuleManager;
this._cacheManager = cacheManager;
if (isIgnored)
{
this.ExplicitReason = "Ignored";
}
this.TypeName = declaringTypeName;
this.Parent = parent;
this.Children = new List<IUnitTestElement>();
this.State = UnitTestElementState.Valid;
this._taskFactory = new UnitTestTaskFactory(this._provider.ID);
}
示例9: SubActivityDao
public SubActivityDao(ISession session,
ISettingsProvider<SubSettings> subSettings,
ICache cache)
: base(session, subSettings)
{
_cache = cache;
}
示例10: SetUp
public void SetUp()
{
_project = new Project(Path.GetFullPath("someProject.csproj"), new ProjectDocument(ProjectType.CSharp));
_project.Value.SetOutputPath("");
_project.Value.SetAssemblyName("someAssembly.dll");
_bus = MockRepository.GenerateMock<IMessageBus>();
_listGenerator = MockRepository.GenerateMock<IGenerateBuildList>();
_configuration = MockRepository.GenerateMock<IConfiguration>();
_buildRunner = MockRepository.GenerateMock<IBuildRunner>();
_testRunner = MockRepository.GenerateMock<ITestRunner>();
_testAssemblyValidator = MockRepository.GenerateMock<IDetermineIfAssemblyShouldBeTested>();
_optimizer = MockRepository.GenerateMock<IOptimizeBuildConfiguration>();
_fs = MockRepository.GenerateMock<IFileSystemService>();
_cache = MockRepository.GenerateMock<ICache>();
_runCache = MockRepository.GenerateMock<IRunResultCache>();
_runInfo = new RunInfo(_project);
_runInfo.ShouldBuild();
_runInfo.SetAssembly(_project.Value.AssemblyName);
_optimizer.Stub(o => o.AssembleBuildConfiguration(new string[] {})).IgnoreArguments().Return(new RunInfo[] { _runInfo });
_preProcessor = MockRepository.GenerateMock<IPreProcessTestruns>();
_preProcessor.Stub(x => x.PreProcess(null)).IgnoreArguments().Return(new PreProcessedTesRuns(null, new RunInfo[] { _runInfo }));
var preProcessors = new IPreProcessTestruns[] { _preProcessor };
var buildPreProcessor = MockRepository.GenerateMock<IPreProcessBuildruns>();
buildPreProcessor.Stub(x => x.PreProcess(null)).IgnoreArguments().Return(new RunInfo[] { _runInfo });
var buildPreProcessors = new IPreProcessBuildruns[] { buildPreProcessor };
_removedTestLocator = MockRepository.GenerateMock<ILocateRemovedTests>();
_buildSessionRunner = new BuildSessionRunner(new BuildConfiguration(null), _cache, _bus, _configuration, _buildRunner, buildPreProcessors, _fs, _runCache);
_consumer = new ProjectChangeConsumer(_bus, _listGenerator, _configuration, _buildSessionRunner, new ITestRunner[] { _testRunner }, _testAssemblyValidator, _optimizer, preProcessors, _removedTestLocator);
}
示例11: lock
ICache ICachingFactory.Create()
{
if (_caches == null)
{
lock (_syncObj)
{
if (_caches == null)
{
var assemblyName = CachingConfig.GetCacheProvider();
if (String.IsNullOrWhiteSpace(assemblyName))
{
_caches = new NoCacheProvider();
}
else
{
var assemblys = assemblyName.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
var handler = Activator.CreateInstance(assemblys[0], assemblys[1]);
var obj = handler.Unwrap();
_caches = obj as ICache;
}
}
}
}
return _caches;
}
示例12: AccessToken
async Task<IAccessToken> IAccessTokenProvider.ProvisionAccessTokenAsync(
IEnumerable<Claim> claims,
IEnumerable<Scope> scopes,
ICache cache
) {
if( cache == null ) {
cache = new NullCache();
}
claims = claims.ToList();
scopes = scopes.ToList();
string cacheKey = TokenCacheKeyBuilder.BuildKey( claims, scopes );
CacheResponse cacheResponse = await cache.GetAsync( cacheKey ).SafeAsync();
if( cacheResponse.Success ) {
SecurityToken securityToken = m_tokenHandler.ReadToken( cacheResponse.Value );
if( securityToken.ValidTo > DateTime.UtcNow.Add( m_tokenRefreshGracePeriod ) ) {
return new AccessToken( cacheResponse.Value );
}
}
IAccessToken token =
await m_accessTokenProvider.ProvisionAccessTokenAsync( claims, scopes ).SafeAsync();
DateTime validTo = m_tokenHandler.ReadToken( token.Token ).ValidTo;
await cache.SetAsync( cacheKey, token.Token, validTo - DateTime.UtcNow ).SafeAsync();
return token;
}
示例13: SplashViewModel
public SplashViewModel(INavigationService navigationService, ITrelloApiSettings settings, ITrello api, ICache cache)
{
_navigationService = navigationService;
_settings = settings;
_cache = cache;
_api = api;
}
示例14: Stop
/// <summary>
/// Stops pruning.
/// </summary>
public void Stop()
{
_timer.Change(Timeout.Infinite, Timeout.Infinite);
_timer.Dispose();
_timer = null;
Cache = null;
}
示例15: DataTableHandler
public DataTableHandler(DataSet dataSet)
{
_cache = new SimpleCache();
_precache = new Hashtable();
_dset = dataSet;
_hasRelations = false;
}