public CacheContextScope CreateScope(bool CacheEnabled = true, Guid trackGuid = default(Guid)) { if (this.CurrentContextStack == null) { this.CurrentContextStack = new AsyncLocal <IImmutableStack <CacheContextStore> > { Value = ImmutableStack <CacheContextStore> .Empty }; } if (this.CurrentContextStack.Value == null) { this.CurrentContextStack.Value = ImmutableStack <CacheContextStore> .Empty; this.CurrentContextStack.Value = this.CurrentContextStack.Value.Push(new CacheContextStore()); } CacheContextStore top = this.CurrentContextStack.Value.IsEmpty ? new CacheContextStore() : this.CurrentContextStack.Value.Peek(); CacheContextStore clone = new CacheContextStore { IsCacheEnabled = CacheEnabled, CacheGuid = (trackGuid == default(Guid)) ? top.CacheGuid : trackGuid }; this.CurrentContextStack.Value = this.CurrentContextStack.Value.Push(clone); return(new CacheContextScope(this.CurrentContextStack)); }
public CacheContextStore(CacheContextStore cacheContext) { this.IsCacheEnabled = cacheContext.IsCacheEnabled; CacheGuid = new Guid(cacheContext.CacheGuid.ToString()); }