public void CachePhaseElement(FrameworkElement phaseElement, int phase) { if (phase < 0) { throw new ArgumentOutOfRangeException("phase"); } if (phase <= 0) { return; } UIElement contentTemplateRoot = IncrementalUpdater.FindContentTemplateRoot(phaseElement); if (contentTemplateRoot != null) { // get the cache for this element ElementCacheRecord elementCacheRecord; if (!this.elementCache.TryGetValue(contentTemplateRoot, out elementCacheRecord)) { elementCacheRecord = new ElementCacheRecord(); this.elementCache.Add(contentTemplateRoot, elementCacheRecord); } // get the cache for this phase int phaseIndex = elementCacheRecord.Phases.BinarySearch(phase); if (phaseIndex < 0) { // not found - insert phaseIndex = ~phaseIndex; elementCacheRecord.Phases.Insert(phaseIndex, phase); elementCacheRecord.ElementsByPhase.Insert(phaseIndex, new List <PhasedElementRecord>()); } List <PhasedElementRecord> phasedElementRecords = elementCacheRecord.ElementsByPhase[phaseIndex]; // first see if the element is already there for (int i = 0; i < phasedElementRecords.Count; i++) { if (phasedElementRecords[i].FrameworkElement == phaseElement) { return; } } // insert the element phasedElementRecords.Add(new PhasedElementRecord(phaseElement)); } }
public void CachePhaseElement(FrameworkElement phaseElement, int phase) { if (phase < 0) { throw new ArgumentOutOfRangeException("phase"); } if (phase <= 0) { return; } UIElement contentTemplateRoot = IncrementalUpdater.FindContentTemplateRoot(phaseElement); if (contentTemplateRoot != null) { // get the cache for this element ElementCacheRecord elementCacheRecord; if (!this.elementCache.TryGetValue(contentTemplateRoot, out elementCacheRecord)) { elementCacheRecord = new ElementCacheRecord(); this.elementCache.Add(contentTemplateRoot, elementCacheRecord); } // get the cache for this phase int phaseIndex = elementCacheRecord.Phases.BinarySearch(phase); if (phaseIndex < 0) { // not found - insert phaseIndex = ~phaseIndex; elementCacheRecord.Phases.Insert(phaseIndex, phase); elementCacheRecord.ElementsByPhase.Insert(phaseIndex, new List<PhasedElementRecord>()); } // insert the element elementCacheRecord.ElementsByPhase[phaseIndex].Add(new PhasedElementRecord(phaseElement)); } }