private KeyContainer FindContainer(string keyName, bool isAllowCreate, out int keysCreatedCount) { keysCreatedCount = 0; if (LocalMemoryStore.IsRootKeyName(keyName)) { return(this.rootContainer); } KeyContainer keyContainer = this.rootContainer; IEnumerable <string> enumerable = from p in keyName.Split(this.splitChar) where !string.IsNullOrEmpty(p) select p; foreach (string text in enumerable) { KeyContainer keyContainer2; if (keyContainer.SubKeys.TryGetValue(text, out keyContainer2)) { keyContainer = keyContainer2; } else { if (!isAllowCreate) { return(null); } keysCreatedCount++; keyContainer2 = new KeyContainer(text, keyContainer); keyContainer.SubKeys[text] = keyContainer2; keyContainer = keyContainer2; } } return(keyContainer); }
public void ApplySnapshotFromXElement(string keyName, int lastInstanceExecuted, XElement rootElement) { keyName = this.NormalizeKeyName(keyName); KeyContainer parent = null; this.locker.WithWriteLock(delegate() { ExTraceGlobals.StoreWriteTracer.TraceDebug <string, int, string>((long)this.identityHash, "{0}: [1] Entering ApplySnapshotFromXElement (Key: {2})", this.identity, this.LastInstanceExecuted, keyName); if (!LocalMemoryStore.IsRootKeyName(keyName)) { KeyContainer keyContainer = this.FindContainer(keyName, true); if (keyContainer != null) { parent = keyContainer.Parent; parent.SubKeys.Remove(keyContainer.Name); } } string keyLastPart = this.GetKeyLastPart(keyName); rootElement.SetAttributeValue("Name", keyLastPart); KeyContainer keyContainer2 = KeyContainer.Create(rootElement, parent); if (parent == null) { this.rootContainer = keyContainer2; } this.SetStats(new int?(lastInstanceExecuted)); ExTraceGlobals.StoreWriteTracer.TraceDebug <string, int>((long)this.identityHash, "{0}: [1] Exiting ApplySnapshotFromXElement", this.identity, lastInstanceExecuted); }); }