//------------------------------------------------------ // // Constructors // //------------------------------------------------------ //------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods /// <summary> /// A null-safe wrapper around Freezable.Clone(). (If a null /// is encountered it returns null.) /// </summary> internal static Freezable Clone(Freezable freezable) { if (freezable == null) { return(null); } return(freezable.Clone()); }
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) { Freezable fvalue = value as Freezable; if (fvalue == null) { return(fvalue); } return(fvalue.CanFreeze ? fvalue.Clone() : fvalue.GetAsFrozen()); }
private static object GetUpdatedComplexProperty(IViewTextRange target, PropertyReference propertyReference, int index, object value, SceneNode.Modification modification) { ReferenceStep firstStep = propertyReference.FirstStep; IProperty property = target.Platform.Metadata.ResolveProperty((IPropertyId)firstStep); if (property != null && RichTextBoxRangeElement.IsComplexProperty((IPlatformMetadata)target.Platform.Metadata, property) && propertyReference.Count > 1) { PropertyReference subReference = RichTextBoxRangeElement.CreateSubReference(propertyReference); object target1; if (target.IsEmpty) { target1 = target.GetPropertyValue((IPropertyId)property); } else { IViewTextPointer viewTextPointer = target.Start; if (!viewTextPointer.IsAtInsertionPosition) { viewTextPointer = viewTextPointer.GetNextInsertionPosition(LogicalDirection.Forward); } target1 = !RichTextBoxElement.IsParagraphProperty(propertyReference) ? viewTextPointer.Parent.GetValue(property) : viewTextPointer.Paragraph.GetValue(property); } Freezable freezable = target1 as Freezable; if (freezable != null) { target1 = (object)freezable.Clone(); } if (target1 != null) { switch (modification) { case SceneNode.Modification.SetValue: target1 = subReference.SetValue(target1, value); break; case SceneNode.Modification.InsertValue: subReference.Insert(target1, index, value); break; case SceneNode.Modification.RemoveValue: subReference.RemoveAt(target1, index); break; default: throw new InvalidEnumArgumentException("modification", (int)modification, typeof(SceneNode.Modification)); } } value = target1; } return(value); }