// Token: 0x06000C1D RID: 3101 RVA: 0x0002D2C4 File Offset: 0x0002B4C4 internal void RegisterNameInternal(string name, object scopedElement) { FrameworkElement frameworkElement; FrameworkContentElement frameworkContentElement; Helper.DowncastToFEorFCE(scopedElement as DependencyObject, out frameworkElement, out frameworkContentElement, false); if (this._templatedParent == null) { if (this._nameMap == null) { this._nameMap = new HybridDictionary(); } this._nameMap[name] = scopedElement; if (frameworkElement != null || frameworkContentElement != null) { this.SetTemplateParentValues(name, scopedElement); return; } } else { if (frameworkElement == null && frameworkContentElement == null) { Hashtable hashtable = TemplateNameScope._templatedNonFeChildrenField.GetValue(this._templatedParent); if (hashtable == null) { hashtable = new Hashtable(1); TemplateNameScope._templatedNonFeChildrenField.SetValue(this._templatedParent, hashtable); } hashtable[name] = scopedElement; return; } this._affectedChildren.Add(scopedElement as DependencyObject); int num; if (frameworkElement != null) { frameworkElement._templatedParent = this._templatedParent; frameworkElement.IsTemplatedParentAnFE = this._isTemplatedParentAnFE; num = (frameworkElement.TemplateChildIndex = (int)this._frameworkTemplate.ChildIndexFromChildName[name]); } else { frameworkContentElement._templatedParent = this._templatedParent; frameworkContentElement.IsTemplatedParentAnFE = this._isTemplatedParentAnFE; num = (frameworkContentElement.TemplateChildIndex = (int)this._frameworkTemplate.ChildIndexFromChildName[name]); } HybridDictionary templateChildLoadedDictionary = this._frameworkTemplate._TemplateChildLoadedDictionary; FrameworkTemplate.TemplateChildLoadedFlags templateChildLoadedFlags = templateChildLoadedDictionary[num] as FrameworkTemplate.TemplateChildLoadedFlags; if (templateChildLoadedFlags != null && (templateChildLoadedFlags.HasLoadedChangedHandler || templateChildLoadedFlags.HasUnloadedChangedHandler)) { BroadcastEventHelper.AddHasLoadedChangeHandlerFlagInAncestry((frameworkElement != null) ? frameworkElement : frameworkContentElement); } StyleHelper.CreateInstanceDataForChild(StyleHelper.TemplateDataField, this._templatedParent, (frameworkElement != null) ? frameworkElement : frameworkContentElement, num, this._frameworkTemplate.HasInstanceValues, ref this._frameworkTemplate.ChildRecordFromChildIndex); } }
internal void RegisterNameInternal(string name, object scopedElement) { FrameworkElement fe; FrameworkContentElement fce; Helper.DowncastToFEorFCE(scopedElement as DependencyObject, out fe, out fce, false /*throwIfNeither*/); int childIndex; // First, though, do we actually have a templated parent? If not, // then we'll just set the properties directly on the element // (this is the serialization scenario). if (_templatedParent == null) { if (_nameMap == null) { _nameMap = new HybridDictionary(); } _nameMap[name] = scopedElement; // No, we don't have a templated parent. Loop through // the shared values (assuming this is an FE/FCE), and set them // directly onto the element. if (fe != null || fce != null) { SetTemplateParentValues(name, scopedElement); } } // We have a templated parent, but is this not a FE/FCE? else if (fe == null && fce == null) { // All we need to do is update the _templatedNonFeChildren list Hashtable nonFeChildren = _templatedNonFeChildrenField.GetValue(_templatedParent); if (nonFeChildren == null) { nonFeChildren = new Hashtable(1); _templatedNonFeChildrenField.SetValue(_templatedParent, nonFeChildren); } nonFeChildren[name] = scopedElement; } // Otherwise, we need to hook this FE/FCE up to the template. else { // Update the list on the templated parent of the named FE/FCEs. _affectedChildren.Add(scopedElement as DependencyObject); // Update the TemplatedParent, IsTemplatedParentAnFE, and TemplateChildIndex. if (fe != null) { fe._templatedParent = _templatedParent; fe.IsTemplatedParentAnFE = _isTemplatedParentAnFE; childIndex = fe.TemplateChildIndex = (int)_frameworkTemplate.ChildIndexFromChildName[name]; } else { fce._templatedParent = _templatedParent; fce.IsTemplatedParentAnFE = _isTemplatedParentAnFE; childIndex = fce.TemplateChildIndex = (int)_frameworkTemplate.ChildIndexFromChildName[name]; } // Entries into the NameScope MUST match the location in the AffectedChildren list Debug.Assert(_affectedChildren.Count == childIndex); // Make updates for the Loaded/Unloaded event listeners (if they're set). HybridDictionary templateChildLoadedDictionary = _frameworkTemplate._TemplateChildLoadedDictionary; FrameworkTemplate.TemplateChildLoadedFlags templateChildLoadedFlags = templateChildLoadedDictionary[childIndex] as FrameworkTemplate.TemplateChildLoadedFlags; if (templateChildLoadedFlags != null) { if (templateChildLoadedFlags.HasLoadedChangedHandler || templateChildLoadedFlags.HasUnloadedChangedHandler) { BroadcastEventHelper.AddHasLoadedChangeHandlerFlagInAncestry((fe != null) ? (DependencyObject)fe : (DependencyObject)fce); } } // Establish databinding instance data. StyleHelper.CreateInstanceDataForChild( StyleHelper.TemplateDataField, _templatedParent, (fe != null) ? (DependencyObject)fe : (DependencyObject)fce, childIndex, _frameworkTemplate.HasInstanceValues, ref _frameworkTemplate.ChildRecordFromChildIndex); } }