public virtual void CopyFrom(BindableObject other) { if (null == other) { return; } Type type1 = this.GetType(); BindableProperty.GetBindablePropertysOfType(type1, out var nameToBindableProperty1); Type type2 = other.GetType(); BindableProperty.GetBindablePropertysOfType(type2, out var nameToBindableProperty2); if (null != nameToBindableProperty1) { foreach (KeyValuePair <string, BindableProperty> keyValuePair in nameToBindableProperty1) { nameToBindableProperty2.TryGetValue(keyValuePair.Key, out var bindableProperty); if (null != bindableProperty && (ChangedPropertiesSet.Contains(bindableProperty) || other.ChangedPropertiesSet.Contains(bindableProperty))) { object value = other.GetValue(bindableProperty); if (null != value) { InternalSetValue(keyValuePair.Value, value); } } } } }
internal void InternalSetValue(BindableProperty property, object value) { if (true == IsBinded) { SetValue(property, value, false, true); } else { if (null == property) { throw new ArgumentNullException(nameof(property)); } object oldvalue = null; if (null == property.DefaultValueCreator) { BindablePropertyContext context = GetOrCreateContext(property); if (null != context) { context.Attributes |= BindableContextAttributes.IsManuallySet; oldvalue = context.Value; context.Value = value; } } else { oldvalue = property.DefaultValueCreator.Invoke(this); } property.PropertyChanged?.Invoke(this, oldvalue, value); OnPropertyChanged(property.PropertyName); OnPropertyChangedWithData(property); } ChangedPropertiesSet.Add(property); }