// Token: 0x06000C6A RID: 3178 RVA: 0x0002E850 File Offset: 0x0002CA50 private static void InvalidateResourceReferences(DependencyObject d, ResourcesChangeInfo info) { LocalValueEnumerator localValueEnumerator = d.GetLocalValueEnumerator(); int count = localValueEnumerator.Count; if (count > 0) { ResourceReferenceExpression[] array = new ResourceReferenceExpression[count]; int num = 0; while (localValueEnumerator.MoveNext()) { LocalValueEntry localValueEntry = localValueEnumerator.Current; ResourceReferenceExpression resourceReferenceExpression = localValueEntry.Value as ResourceReferenceExpression; if (resourceReferenceExpression != null && info.Contains(resourceReferenceExpression.ResourceKey, false)) { array[num] = resourceReferenceExpression; num++; } } ResourcesChangedEventArgs e = new ResourcesChangedEventArgs(info); for (int i = 0; i < num; i++) { array[i].InvalidateExpressionValue(d, e); } } }
// Token: 0x06000BA9 RID: 2985 RVA: 0x0002AF28 File Offset: 0x00029128 internal virtual void RemoveInflatedListener(ResourceReferenceExpression listener) { if (this._inflatedList != null) { this._inflatedList.Remove(listener); } }
// Token: 0x06000BA8 RID: 2984 RVA: 0x0002AF05 File Offset: 0x00029105 internal virtual void AddInflatedListener(ResourceReferenceExpression listener) { if (this._inflatedList == null) { this._inflatedList = new WeakReferenceList(this); } this._inflatedList.Add(listener); }
// Token: 0x06007E6A RID: 32362 RVA: 0x00235968 File Offset: 0x00233B68 private void InvalidateTargetSubProperty(object sender, EventArgs args) { ResourceReferenceExpression resourceReferenceExpression = (ResourceReferenceExpression)this.Target; if (resourceReferenceExpression != null) { resourceReferenceExpression.InvalidateTargetSubProperty(sender, args); return; } this.RemoveChangedHandler(); }
// Token: 0x06000BA5 RID: 2981 RVA: 0x0002AE64 File Offset: 0x00029064 private void OnInflated() { if (this._inflatedList != null) { foreach (object obj in this._inflatedList) { ResourceReferenceExpression resourceReferenceExpression = (ResourceReferenceExpression)obj; resourceReferenceExpression.OnDeferredResourceInflated(this); } } }
private void InvalidateTargetSubProperty(object sender, EventArgs args) { ResourceReferenceExpression expression = (ResourceReferenceExpression)Target; if (expression != null) { expression.InvalidateTargetSubProperty(sender, args); } else { RemoveChangedHandler(); } }
/// <summary> /// Invalidates all properties that reference a resource. /// NOTE: The return value for this method indicates whether or not a ResourceReference /// property was found on the given object. This is to take care of the special case when /// programmatically changing a ResourceReference property value does not reflect on the /// bit stored on FrameworkElement or FrameworkContentElement that indicates whether /// the current instance has ResourceReference values set on it. This current operation /// is a point of synchronization for this flag. /// </summary> /// <remarks> /// This methods is called when one of the following operations occurred. /// 1) A tree change /// 2) A resource dictionary change /// 3) A modification to a single entry in a dictionary /// </remarks> private static void InvalidateResourceReferences( DependencyObject d, ResourcesChangeInfo info) { Debug.Assert(d != null, "Must have non-null current node"); // Find properties that have resource reference value LocalValueEnumerator localValues = d.GetLocalValueEnumerator(); int localValuesCount = localValues.Count; if (localValuesCount > 0) { // Resource reference invalidation involves two passes - first to // pick out what we need to invalidate, and the second to do the // actual invalidation. This is needed because LocalValueEnumerator // will halt if any local values have changed, which can happen // depending on what people are doing in their OnPropertyChanged // callback. // The following array is used to track the ResourceReferenceExpressions that we find ResourceReferenceExpression[] resources = new ResourceReferenceExpression[localValuesCount]; int invalidationCount = 0; // Pass #1 - find what needs invalidation while (localValues.MoveNext()) { // Is this a resource reference? ResourceReferenceExpression resource = localValues.Current.Value as ResourceReferenceExpression; if (resource != null) { // Record this property if it is referring // to a resource that is being changed if (info.Contains(resource.ResourceKey, false /*isImplicitStyleKey*/)) { resources[invalidationCount] = resource; invalidationCount++; } } } ResourcesChangedEventArgs args = new ResourcesChangedEventArgs(info); // Pass #2 - actually make the invalidation calls, now that we're // outside the LocalValueEnumerator. for (int i = 0; i < invalidationCount; i++) { // Let the resource reference throw away its cache // and invalidate the property in which it's held // re-evaluate expression resources[i].InvalidateExpressionValue(d, args); } } }
internal virtual void RemoveInflatedListener(ResourceReferenceExpression listener) { Debug.Assert(_inflatedList != null); if (_inflatedList != null) { _inflatedList.Remove(listener); } }
internal virtual void AddInflatedListener(ResourceReferenceExpression listener) { if (_inflatedList == null) { _inflatedList = new WeakReferenceList(this); } _inflatedList.Add(listener); }
public ResourceReferenceExpressionWeakContainer(ResourceReferenceExpression target) : base(target) {}
//+---------------------------------------------------------------------------------------------------------------- // // SetTemplateParentValues // // This method takes the "template parent values" (those that look like local values in the template), which // are ordinarily shared, and sets them as local values on the FE/FCE that was just created. This is used // during serialization. // //+---------------------------------------------------------------------------------------------------------------- internal static void SetTemplateParentValues( string name, object element, FrameworkTemplate frameworkTemplate, ref ProvideValueServiceProvider provideValueServiceProvider) { int childIndex; // Loop through the shared values, and set them onto the element. FrugalStructList<ChildRecord> childRecordFromChildIndex; HybridDictionary childIndexFromChildName; // Seal the template, and get the name->index and index->ChildRecord mappings if (!frameworkTemplate.IsSealed) { frameworkTemplate.Seal(); } childIndexFromChildName = frameworkTemplate.ChildIndexFromChildName; childRecordFromChildIndex = frameworkTemplate.ChildRecordFromChildIndex; // Calculate the child index childIndex = StyleHelper.QueryChildIndexFromChildName(name, childIndexFromChildName); // Do we have a ChildRecord for this index (i.e., there's some property set on it)? if (childIndex < childRecordFromChildIndex.Count) { // Yes, get the record. ChildRecord child = (ChildRecord)childRecordFromChildIndex[childIndex]; // Loop through the properties which are in some way set on this child for (int i = 0; i < child.ValueLookupListFromProperty.Count; i++) { // And for each of those properties, loop through the potential values specified in the template // for that property on that child. for (int j = 0; j < child.ValueLookupListFromProperty.Entries[i].Value.Count; j++) { // Get this value (in valueLookup) ChildValueLookup valueLookup; valueLookup = (ChildValueLookup)child.ValueLookupListFromProperty.Entries[i].Value.List[j]; // See if this value is one that is considered to be locally set on the child element if (valueLookup.LookupType == ValueLookupType.Simple || valueLookup.LookupType == ValueLookupType.Resource || valueLookup.LookupType == ValueLookupType.TemplateBinding) { // This shared value is for this element, so we'll set it. object value = valueLookup.Value; // If this is a TemplateBinding, put on an expression for it, so that it can // be represented correctly (e.g. for serialization). Otherwise, keep it as an ME. if (valueLookup.LookupType == ValueLookupType.TemplateBinding) { value = new TemplateBindingExpression(value as TemplateBindingExtension); } // Dynamic resources need to be converted to an expression also. else if (valueLookup.LookupType == ValueLookupType.Resource) { value = new ResourceReferenceExpression(value); } // Bindings are handled as just an ME // Set the value directly onto the element. MarkupExtension me = value as MarkupExtension; if (me != null) { // This is provided for completeness, but really there's only a few // MEs that survive TemplateBamlRecordReader. E.g. NullExtension would // have been converted to a null by now. There's only a few MEs that // are preserved, e.g. Binding and DynamicResource. Other MEs, such as // StaticResource, wouldn't be able to ProvideValue here, because we don't // have a ParserContext. if (provideValueServiceProvider == null) { provideValueServiceProvider = new ProvideValueServiceProvider(); } provideValueServiceProvider.SetData(element, valueLookup.Property); value = me.ProvideValue(provideValueServiceProvider); provideValueServiceProvider.ClearData(); } (element as DependencyObject).SetValue(valueLookup.Property, value); //sharedDp.Dp, value ); } } } } }
// Token: 0x06007E69 RID: 32361 RVA: 0x0023595C File Offset: 0x00233B5C public ResourceReferenceExpressionWeakContainer(ResourceReferenceExpression target) : base(target) { }
/// <summary>Sets the value of a dependency property.</summary> /// <param name="dp">The dependency property identifier of the property to set.</param> /// <param name="value">The new value.</param> // Token: 0x0600067D RID: 1661 RVA: 0x00014260 File Offset: 0x00012460 public void SetValue(DependencyProperty dp, object value) { if (this._sealed) { throw new InvalidOperationException(SR.Get("CannotChangeAfterSealed", new object[] { "FrameworkElementFactory" })); } if (dp == null) { throw new ArgumentNullException("dp"); } if (!dp.IsValidValue(value) && !(value is MarkupExtension) && !(value is DeferredReference)) { throw new ArgumentException(SR.Get("InvalidPropertyValue", new object[] { value, dp.Name })); } if (StyleHelper.IsStylingLogicalTree(dp, value)) { throw new NotSupportedException(SR.Get("ModifyingLogicalTreeViaStylesNotImplemented", new object[] { value, "FrameworkElementFactory.SetValue" })); } if (dp.ReadOnly) { throw new ArgumentException(SR.Get("ReadOnlyPropertyNotAllowed", new object[] { dp.Name, base.GetType().Name })); } ResourceReferenceExpression resourceReferenceExpression = value as ResourceReferenceExpression; DynamicResourceExtension dynamicResourceExtension = value as DynamicResourceExtension; object obj = null; if (resourceReferenceExpression != null) { obj = resourceReferenceExpression.ResourceKey; } else if (dynamicResourceExtension != null) { obj = dynamicResourceExtension.ResourceKey; } if (obj != null) { this.UpdatePropertyValueList(dp, PropertyValueType.Resource, obj); return; } TemplateBindingExtension templateBindingExtension = value as TemplateBindingExtension; if (templateBindingExtension == null) { this.UpdatePropertyValueList(dp, PropertyValueType.Set, value); return; } this.UpdatePropertyValueList(dp, PropertyValueType.TemplateBinding, templateBindingExtension); }