public SetValueArgs(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes) { Property = property; Context = context; Value = value; CurrentlyApplying = currentlyApplying; Attributes = attributes; }
public static int SetValueW([MarshalAs(UnmanagedType.LPWStr)] string fileName, int fieldIndex, int unitIndex, int fieldType, IntPtr fieldValue, int flags) { SetValueResult result; ContentFieldType fldType = (ContentFieldType)fieldType; SetValueFlags svFlags = (SetValueFlags)flags; callSignature = String.Format("ContentSetValue '{0}' ({1}/{2}/{3})", fileName, fieldIndex, unitIndex, svFlags.ToString()); try { ContentValue value = new ContentValue(fieldValue, fldType); result = Plugin.SetValue(fileName, fieldIndex, unitIndex, fldType, value.StrValue, svFlags); TraceCall(TraceLevel.Info, String.Format("{0} - {1}", result.ToString(), value.StrValue)); } catch (Exception ex) { ProcessException(ex); result = SetValueResult.NoSuchField; } return((int)result); }
void SetValueActual(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, bool forceSendChangeSignal, SetValueFlags attributes, bool silent = false) { object original = context.Value; bool raiseOnEqual = (attributes & SetValueFlags.RaiseOnEqual) != 0; bool clearDynamicResources = (attributes & SetValueFlags.ClearDynamicResource) != 0; bool clearOneWayBindings = (attributes & SetValueFlags.ClearOneWayBindings) != 0; bool clearTwoWayBindings = (attributes & SetValueFlags.ClearTwoWayBindings) != 0; bool same = ReferenceEquals(context.Property, BindingContextProperty) ? ReferenceEquals(value, original) : Equals(value, original); if (!silent && (!same || raiseOnEqual)) { property.PropertyChanging?.Invoke(this, original, value); OnPropertyChanging(property.PropertyName); } if (!same || raiseOnEqual) { context.Value = value; } context.Attributes &= ~BindableContextAttributes.IsDefaultValue; context.Attributes &= ~BindableContextAttributes.IsDefaultValueCreated; if ((context.Attributes & BindableContextAttributes.IsDynamicResource) != 0 && clearDynamicResources) { RemoveDynamicResource(property); } BindingBase binding = context.Binding; if (binding != null) { if (clearOneWayBindings && binding.GetRealizedMode(property) == BindingMode.OneWay || clearTwoWayBindings && binding.GetRealizedMode(property) == BindingMode.TwoWay) { RemoveBinding(property, context); binding = null; } } if (!silent) { if ((!same || raiseOnEqual)) { property.PropertyChanged?.Invoke(this, original, value); if (binding != null && !currentlyApplying) { _applying = true; binding.Apply(true); _applying = false; } OnPropertyChanged(property.PropertyName); } else if (true == same && true == forceSendChangeSignal) { if (binding != null && !currentlyApplying) { _applying = true; binding.Apply(true); _applying = false; } OnPropertyChanged(property.PropertyName); } } }
internal void SetValueCore(BindableProperty property, object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, bool forceSendChangeSignal) { bool checkAccess = (privateAttributes & SetValuePrivateFlags.CheckAccess) != 0; bool manuallySet = (privateAttributes & SetValuePrivateFlags.ManuallySet) != 0; bool silent = (privateAttributes & SetValuePrivateFlags.Silent) != 0; bool fromStyle = (privateAttributes & SetValuePrivateFlags.FromStyle) != 0; bool converted = (privateAttributes & SetValuePrivateFlags.Converted) != 0; if (property == null) { throw new ArgumentNullException(nameof(property)); } if (checkAccess && property.IsReadOnly) { Debug.WriteLine("Can not set the BindableProperty \"{0}\" because it is readonly.", property.PropertyName); return; } if (!converted && !property.TryConvert(ref value)) { Console.WriteLine("SetValue", "Can not convert {0} to type '{1}'", value, property.ReturnType); return; } if (property.ValidateValue != null && !property.ValidateValue(this, value)) { throw new ArgumentException("Value was an invalid value for " + property.PropertyName, nameof(value)); } if (property.CoerceValue != null) { value = property.CoerceValue(this, value); } BindablePropertyContext context = GetOrCreateContext(property); if (manuallySet) { context.Attributes |= BindableContextAttributes.IsManuallySet; context.Attributes &= ~BindableContextAttributes.IsSetFromStyle; } else { context.Attributes &= ~BindableContextAttributes.IsManuallySet; } if (fromStyle) { context.Attributes |= BindableContextAttributes.IsSetFromStyle; } // else omitted on purpose bool currentlyApplying = _applying; if ((context.Attributes & BindableContextAttributes.IsBeingSet) != 0) { Queue <SetValueArgs> delayQueue = context.DelayedSetters; if (delayQueue == null) { context.DelayedSetters = delayQueue = new Queue <SetValueArgs>(); } delayQueue.Enqueue(new SetValueArgs(property, context, value, currentlyApplying, attributes)); } else { context.Attributes |= BindableContextAttributes.IsBeingSet; SetValueActual(property, context, value, currentlyApplying, forceSendChangeSignal, attributes, silent); Queue <SetValueArgs> delayQueue = context.DelayedSetters; if (delayQueue != null) { while (delayQueue.Count > 0) { SetValueArgs s = delayQueue.Dequeue(); SetValueActual(s.Property, s.Context, s.Value, s.CurrentlyApplying, forceSendChangeSignal, s.Attributes); } context.DelayedSetters = null; } context.Attributes &= ~BindableContextAttributes.IsBeingSet; } }
internal void SetValueCore(BindableProperty property, object value, SetValueFlags attributes = SetValueFlags.None) { SetValueCore(property, value, attributes, SetValuePrivateFlags.Default, false); }
void SetValueActual(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes, bool silent = false) { object original = context.Value; bool raiseOnEqual = (attributes & SetValueFlags.RaiseOnEqual) != 0; bool clearDynamicResources = (attributes & SetValueFlags.ClearDynamicResource) != 0; bool clearOneWayBindings = (attributes & SetValueFlags.ClearOneWayBindings) != 0; bool clearTwoWayBindings = (attributes & SetValueFlags.ClearTwoWayBindings) != 0; bool same = ReferenceEquals(context.Property, BindingContextProperty) ? ReferenceEquals(value, original) : Equals(value, original); if (!silent && (!same || raiseOnEqual)) { property.PropertyChanging?.Invoke(this, original, value); OnPropertyChanging(property.PropertyName); } if (!same || raiseOnEqual) { context.Value = value; } context.Attributes &= ~BindableContextAttributes.IsDefaultValue; context.Attributes &= ~BindableContextAttributes.IsDefaultValueCreated; if ((context.Attributes & BindableContextAttributes.IsDynamicResource) != 0 && clearDynamicResources) { RemoveDynamicResource(property); } BindingBase binding = context.Binding; if (binding != null) { if (clearOneWayBindings && binding.GetRealizedMode(property) == BindingMode.OneWay || clearTwoWayBindings && binding.GetRealizedMode(property) == BindingMode.TwoWay) { RemoveBinding(property, context); binding = null; } } PropertyToGroup.TryGetValue(property, out HashSet <BindableProperty> propertyGroup); if (!silent && (!same || raiseOnEqual)) { property.PropertyChanged?.Invoke(this, original, value); if (binding != null && !currentlyApplying) { applying = true; binding.Apply(true); applying = false; } OnPropertyChanged(property.PropertyName); if (null != propertyGroup) { foreach (var relativeProperty in propertyGroup) { if (relativeProperty != property) { var relativeContext = GetOrCreateContext(relativeProperty); var relativeBinding = relativeContext.Binding; if (null != relativeBinding) { applying = true; relativeBinding.Apply(true); applying = false; } OnPropertyChanged(relativeProperty.PropertyName); } } } OnPropertyChangedWithData(property); } }
public override SetValueResult SetValue(string fileName, int fieldIndex, int unitIndex, ContentFieldType fieldType, string fieldValue, SetValueFlags flags) { if (String.IsNullOrEmpty(fileName) && fieldIndex < 0) // change attributes operation has ended { return(SetValueResult.NoSuchField); } if (String.IsNullOrEmpty(fieldValue)) { return(SetValueResult.NoSuchField); } SetValueResult result = SetValueResult.NoSuchField; DateTime created = DateTime.Parse(fieldValue); bool dateOnly = (flags & SetValueFlags.OnlyDate) != 0; if (Directory.Exists(fileName)) { DirectoryInfo dirInfo = new DirectoryInfo(fileName); if (SetCombinedDateTime(ref created, dirInfo.CreationTime, fieldType, dateOnly)) { Directory.SetCreationTime(fileName, created); result = SetValueResult.Success; } } else if (File.Exists(fileName)) { FileInfo fileInfo = new FileInfo(fileName); if (SetCombinedDateTime(ref created, fileInfo.CreationTime, fieldType, dateOnly)) { File.SetCreationTime(fileName, created); result = SetValueResult.Success; } } else { result = SetValueResult.FileError; } return(result); }
public virtual SetValueResult SetValue(string fileName, int fieldIndex, int unitIndex, ContentFieldType fieldType, string fieldValue, SetValueFlags flags) { return(SetValueResult.NoSuchField); }