/// <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> public void SetValue(DependencyProperty dp, object value) { if (this.@sealed) { throw new InvalidOperationException("Can't change FrameworkElementFactory after sealed"); } if (dp == null) { throw new ArgumentNullException("dp"); } if (!dp.IsValidValue(value) && !(value is MarkupExtension) && !(value is DeferredReference) && !(value is BindingBase)) { object[] objArray1 = new object[] { value, dp.Name }; throw new ArgumentException("InvalidPropertyValue"); } /* * //if (StyleHelper.IsStylingLogicalTree(dp, value)) * //{ * // throw new NotSupportedException("ModifyingLogicalTreeViaStylesNotImplemented"); * //} */ if (dp.ReadOnly) { throw new ArgumentException("ReadOnlyPropertyNotAllowed"); } ResourceReferenceExpression resourceReferenceExpression = value as ResourceReferenceExpression; object resourceKey = null; if (resourceReferenceExpression != null) { resourceKey = resourceReferenceExpression.ResourceKey; } if (resourceKey != null) { this.UpdatePropertyValueList(dp, PropertyValueType.Resource, resourceKey); return; } TemplateBindingExtension templateBindingExtension = value as TemplateBindingExtension; if (templateBindingExtension != null) { this.UpdatePropertyValueList(dp, PropertyValueType.TemplateBinding, templateBindingExtension); return; } this.UpdatePropertyValueList(dp, PropertyValueType.Set, value); }
/// <summary>Converts the specified <see langword="ResourceReferenceExpression" /> object to the specified type.</summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context. </param> /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> to use as the current culture. </param> /// <param name="value">The object to convert.</param> /// <param name="destinationType">The type to convert to.</param> /// <returns>The converted value.</returns> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="destinationType" /> is <see langword="null" />.</exception> /// <exception cref="T:System.ArgumentException"> /// <paramref name="value" /> must be of type <see langword="ResourceReferenceExpression" />.</exception> // Token: 0x06001D09 RID: 7433 RVA: 0x00087884 File Offset: 0x00085A84 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { ResourceReferenceExpression resourceReferenceExpression = value as ResourceReferenceExpression; if (resourceReferenceExpression == null) { throw new ArgumentException(SR.Get("MustBeOfType", new object[] { "value", "ResourceReferenceExpression" })); } if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(MarkupExtension)) { return(new DynamicResourceExtension(resourceReferenceExpression.ResourceKey)); } return(base.ConvertTo(context, culture, value, destinationType)); }
/// <summary> /// TypeConverter method implementation. /// </summary> /// <param name="context"> /// ITypeDescriptorContext /// </param> /// <param name="culture"> /// current culture (see CLR specs) /// </param> /// <param name="value"> /// value to convert from /// </param> /// <param name="destinationType"> /// Type to convert to /// </param> /// <returns> /// converted value /// </returns> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { // Validate Input Arguments ResourceReferenceExpression expr = value as ResourceReferenceExpression; if (expr == null) { throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "ResourceReferenceExpression")); } if (destinationType == null) { throw new ArgumentNullException("destinationType"); } // MarkupExtension if (destinationType == typeof(MarkupExtension)) { return(new DynamicResourceExtension(expr.ResourceKey)); } return(base.ConvertTo(context, culture, value, destinationType)); }
public ResourceReferenceExpressionWeakContainer(ResourceReferenceExpression target) : base(target) { }
private void WriteInternalState(ResourceReferenceExpression.InternalState reqFlag, bool set) { if (set) { ResourceReferenceExpression resourceReferenceExpression = this; resourceReferenceExpression.state = (ResourceReferenceExpression.InternalState)((byte)(resourceReferenceExpression.state | reqFlag)); return; } ResourceReferenceExpression resourceReferenceExpression1 = this; resourceReferenceExpression1.state = (ResourceReferenceExpression.InternalState)((byte)((byte)resourceReferenceExpression1.state & (byte)(~reqFlag))); }
private bool ReadInternalState(ResourceReferenceExpression.InternalState reqFlag) { return (byte)(this.state & reqFlag) != 0; }