private void OnChanged(IPropertyChanged changed) { lock (locker) { if (isSuppressingChange) { return; } isSuppressingChange = true; } var value = changed.NewValue; if (value == null) { Object = null; Directory.DeleteTree(); Directory.Refresh(); } else { Object = new DbObjectNode(Database, (IRxObject)changed.NewValue, Directory); } lock (locker) { isSuppressingChange = false; } }
/// <summary> /// 验证属性值变更状态是否满足要求 /// </summary> /// <param name="propertyChanged"></param> /// <param name="context"></param> /// <returns></returns> public static bool IsCondition(IPropertyChanged propertyChanged, AbstractRequestContext context) { if (propertyChanged.PropertyChanged == PropertyChangedState.Ignore) { return(true); } var changedVersion = context.GetPropertyVersion(propertyChanged.Property); switch (changedVersion) { case -1: { return(true); } case 0: { return(propertyChanged.PropertyChanged == PropertyChangedState.Unchanged); } case int version when version > 0: { return(propertyChanged.PropertyChanged == PropertyChangedState.Changed); } default: { return(false); } } }
private void GetPropertyInfo(object src, object dest, string srcProperty, string destProperty) { var lastObj = GetObjectFromString(srcProperty, src, out srcPropertyLast); if (lastObj != null && lastObj is IPropertyChanged) { foreach (PropertyInfo propertyInfo in lastObj.GetType().GetProperties()) { if (propertyInfo.Name == srcPropertyLast) { srcPropertyInfo = propertyInfo; break; } } srcObject = lastObj as IPropertyChanged; srcObject.PropertyChanged += Binding_PropertyChanged; } lastObj = GetObjectFromString(destProperty, dest, out destPropertyLast); if (lastObj != null) { foreach (PropertyInfo propertyInfo in lastObj.GetType().GetProperties()) { if (propertyInfo.Name == destPropertyLast) { destPropertyInfo = propertyInfo; break; } } destObject = lastObj; } }
public SudokuController(IPropertyChanged propertyChanged) { _propertyChanged = propertyChanged; _game = new Sudoku.Game(); _game.create(); _propertyChanged.NotifyPropertyChanged(); }
/// <summary>Performs the logical operation "target.PropertyChanged += handler", /// where 'target' is located in another AppDomain, using this helper as an /// intermediary so that the subscription works correctly.</summary> public CrossDomainPropertyChangeHelper(IPropertyChanged target, PropertyChangedDelegate handler) { Debug.Assert(RemotingServices.IsTransparentProxy(target)); _handler = handler; target.PropertyChanged += Intermediary; // Honestly I don't know what I am doing. Tried to figure it out, failed. ((ILease)RemotingServices.GetLifetimeService(this)).Register(this); // register self as sponsor }
public static bool Change <T>(this IPropertyChanged input, ref T field, T value, [CallerMemberName] string propertyName = "") { if (EqualityComparer <T> .Default.Equals(field, value)) { return(false); } field = value; input.Changed(propertyName); return(true); }
public static bool Change <T>(this IPropertyChanged input, ref T field, T value, Expression <Func <T> > propertyName) { if (EqualityComparer <T> .Default.Equals(field, value)) { return(false); } field = value; input.Changed(propertyName); return(true); }
public static void Changed <T>(this IPropertyChanged input, Expression <Func <T> > propertyName) { if (propertyName == null) { throw new ArgumentNullException(nameof(propertyName)); } var body = propertyName.Body as MemberExpression; if (body == null) { throw new ArgumentNullException($"{nameof(propertyName)}.{nameof(propertyName.Body)}"); } input.OnPropertyChanged(body.Member.Name); }
private void OnChanged(IPropertyChanged changed) { lock (locker) { if (isSuppressingChange) { return; } } var value = changed.NewValue; if (value == null) { File.Delete(); } else { System.IO.File.WriteAllText(File.FullName, (string)TypeConverter.Convert(changed.NewValue, typeof(string))); } Database.NotifyGlobalChanged(changed); }
public Binding(IPropertyChanged source, string sourcePropertyName, IPropertyChanged target, string targetPropertyName, BindingType type = BindingType.TwoWay, IValueConverter converter = null) { this.source = source; this.sourcePropertyName = sourcePropertyName; this.target = target; this.targetPropertyName = targetPropertyName; this.type = type; this.converter = converter == null ? new NoOpCoverter() : converter; if (type == BindingType.TwoWay || type == BindingType.OneWay) { sourceToTarget = true; source.PropertyChanged += SourceChanged; } if (type == BindingType.TwoWay || type == BindingType.OneWayToSource) { targetToSource = true; target.PropertyChanged += TargetChanged; } ValidateBinding(); }
public void SetParent(object parent, PropertyInfo propertyInfo) { _parent = parent as IPropertyChanged; _propertyInfo = propertyInfo; }
protected void OnGlobalChanged(IPropertyChanged changed) { GlobalChanged?.Invoke(changed); }
public static void Changed(this IPropertyChanged input, [CallerMemberName] string propertyName = "") => input.OnPropertyChanged(propertyName);
internal void NotifyGlobalChanged(IPropertyChanged changed) { OnGlobalChanged(changed); }