// 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); } }
// Token: 0x06000314 RID: 788 RVA: 0x00008A70 File Offset: 0x00006C70 internal static void AddOrRemoveHasLoadedChangeHandlerFlag(DependencyObject d, DependencyObject oldParent, DependencyObject newParent) { bool flag = BroadcastEventHelper.SubtreeHasLoadedChangeHandlerHelper(d); if (flag) { if (oldParent == null && newParent != null) { BroadcastEventHelper.AddHasLoadedChangeHandlerFlagInAncestry(newParent); return; } if (oldParent != null && newParent == null) { BroadcastEventHelper.RemoveHasLoadedChangeHandlerFlagInAncestry(oldParent); } } }
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); } }
// Token: 0x06000691 RID: 1681 RVA: 0x00014908 File Offset: 0x00012B08 internal DependencyObject InstantiateTree(UncommonField <HybridDictionary[]> dataField, DependencyObject container, DependencyObject parent, List <DependencyObject> affectedChildren, ref List <DependencyObject> noChildIndexChildren, ref FrugalStructList <ChildPropertyDependent> resourceDependents) { EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordXamlBaml, EventTrace.Level.Verbose, EventTrace.Event.WClientParseFefCrInstBegin); FrameworkElement frameworkElement = container as FrameworkElement; bool flag = frameworkElement != null; DependencyObject dependencyObject = null; if (this._text != null) { IAddChild addChild = parent as IAddChild; if (addChild == null) { throw new InvalidOperationException(SR.Get("TypeMustImplementIAddChild", new object[] { parent.GetType().Name })); } addChild.AddText(this._text); } else { dependencyObject = this.CreateDependencyObject(); EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordXamlBaml, EventTrace.Level.Verbose, EventTrace.Event.WClientParseFefCrInstEnd); FrameworkObject frameworkObject = new FrameworkObject(dependencyObject); Visual3D visual3D = null; bool flag2 = false; if (!frameworkObject.IsValid) { visual3D = (dependencyObject as Visual3D); if (visual3D != null) { flag2 = true; } } bool isFE = frameworkObject.IsFE; if (!flag2) { FrameworkElementFactory.NewNodeBeginInit(isFE, frameworkObject.FE, frameworkObject.FCE); if (StyleHelper.HasResourceDependentsForChild(this._childIndex, ref resourceDependents)) { frameworkObject.HasResourceReference = true; } FrameworkElementFactory.UpdateChildChains(this._childName, this._childIndex, isFE, frameworkObject.FE, frameworkObject.FCE, affectedChildren, ref noChildIndexChildren); FrameworkElementFactory.NewNodeStyledParentProperty(container, flag, isFE, frameworkObject.FE, frameworkObject.FCE); if (this._childIndex != -1) { StyleHelper.CreateInstanceDataForChild(dataField, container, dependencyObject, this._childIndex, this._frameworkTemplate.HasInstanceValues, ref this._frameworkTemplate.ChildRecordFromChildIndex); } if (this.HasLoadedChangeHandler) { BroadcastEventHelper.AddHasLoadedChangeHandlerFlagInAncestry(dependencyObject); } } else if (this._childName != null) { affectedChildren.Add(dependencyObject); } else { if (noChildIndexChildren == null) { noChildIndexChildren = new List <DependencyObject>(4); } noChildIndexChildren.Add(dependencyObject); } if (container == parent) { TemplateNameScope value = new TemplateNameScope(container); NameScope.SetNameScope(dependencyObject, value); if (flag) { frameworkElement.TemplateChild = frameworkObject.FE; } else { FrameworkElementFactory.AddNodeToLogicalTree((FrameworkContentElement)parent, this._type, isFE, frameworkObject.FE, frameworkObject.FCE); } } else { this.AddNodeToParent(parent, frameworkObject); } if (!flag2) { StyleHelper.InvalidatePropertiesOnTemplateNode(container, frameworkObject, this._childIndex, ref this._frameworkTemplate.ChildRecordFromChildIndex, false, this); } else { for (int i = 0; i < this.PropertyValues.Count; i++) { if (this.PropertyValues[i].ValueType != PropertyValueType.Set) { throw new NotSupportedException(SR.Get("Template3DValueOnly", new object[] { this.PropertyValues[i].Property })); } object obj = this.PropertyValues[i].ValueInternal; Freezable freezable = obj as Freezable; if (freezable != null && !freezable.CanFreeze) { obj = freezable.Clone(); } MarkupExtension markupExtension = obj as MarkupExtension; if (markupExtension != null) { ProvideValueServiceProvider provideValueServiceProvider = new ProvideValueServiceProvider(); provideValueServiceProvider.SetData(visual3D, this.PropertyValues[i].Property); obj = markupExtension.ProvideValue(provideValueServiceProvider); } visual3D.SetValue(this.PropertyValues[i].Property, obj); } } for (FrameworkElementFactory frameworkElementFactory = this._firstChild; frameworkElementFactory != null; frameworkElementFactory = frameworkElementFactory._nextSibling) { frameworkElementFactory.InstantiateTree(dataField, container, dependencyObject, affectedChildren, ref noChildIndexChildren, ref resourceDependents); } if (!flag2) { FrameworkElementFactory.NewNodeEndInit(isFE, frameworkObject.FE, frameworkObject.FCE); } } return(dependencyObject); }