diff --git a/Source/Csla/BusinessBindingListBase.cs b/Source/Csla/BusinessBindingListBase.cs index 01d0925f29..214e508030 100644 --- a/Source/Csla/BusinessBindingListBase.cs +++ b/Source/Csla/BusinessBindingListBase.cs @@ -861,33 +861,6 @@ bool ITrackStatus.IsDeleted #endregion - #region Serialization Notification - - [NonSerialized] - [NotUndoable] - private bool _deserialized = false; - - /// - /// This method is called on a newly deserialized object - /// after deserialization is complete. - /// - [EditorBrowsable(EditorBrowsableState.Advanced)] - protected override void OnDeserialized() - { - _deserialized = true; - base.OnDeserialized(); - - foreach (IEditableBusinessObject child in this) - { - child.SetParent(this); - } - - foreach (IEditableBusinessObject child in DeletedList) - child.SetParent(this); - } - - #endregion - #region Child Data Access /// @@ -1361,7 +1334,7 @@ void IDataPortalTarget.Child_OnDataPortalException(DataPortalEventArgs e, Except [EditorBrowsable(EditorBrowsableState.Never)] protected override void Child_PropertyChanged(object sender, PropertyChangedEventArgs e) { - if (_deserialized && RaiseListChangedEvents && e != null) + if (RaiseListChangedEvents && e != null) { for (int index = 0; index < Count; index++) { diff --git a/Source/Csla/BusinessListBase.cs b/Source/Csla/BusinessListBase.cs index 350e8d7138..38095b1794 100644 --- a/Source/Csla/BusinessListBase.cs +++ b/Source/Csla/BusinessListBase.cs @@ -610,7 +610,6 @@ private void AcceptChanges(int parentEditLevel) if (child.EditLevelAdded > EditLevel) DeletedList.RemoveAt(index); } - if (EditLevel < 0) EditLevel = 0; } @@ -883,24 +882,6 @@ bool ITrackStatus.IsDeleted #endregion - #region Serialization Notification - - /// - /// Reset parent references on deserialization. - /// - [EditorBrowsable(EditorBrowsableState.Advanced)] - protected override void OnDeserialized() - { - base.OnDeserialized(); - foreach (IEditableBusinessObject child in this) - child.SetParent(this); - - foreach (IEditableBusinessObject child in DeletedList) - child.SetParent(this); - } - - #endregion - #region Child Data Access /// diff --git a/Source/Csla/Core/ExtendedBindingList.cs b/Source/Csla/Core/ExtendedBindingList.cs index af384889a7..15af2198a4 100644 --- a/Source/Csla/Core/ExtendedBindingList.cs +++ b/Source/Csla/Core/ExtendedBindingList.cs @@ -249,32 +249,11 @@ protected virtual void OnRemoveEventHooks(T item) child.ChildChanged -= Child_Changed; } - /// - /// This method is called on a newly deserialized object - /// after deserialization is complete. - /// - [EditorBrowsable(EditorBrowsableState.Advanced)] - protected virtual void OnDeserialized() - { - // do nothing - this is here so a subclass - // could override if needed - } - void ISerializationNotification.Deserialized() { // don't rehook events here, because the MobileFormatter has // created new objects and so the lists will auto-subscribe - // the events - OnDeserialized(); - } - - [System.Runtime.Serialization.OnDeserialized] - private void OnDeserializedHandler(System.Runtime.Serialization.StreamingContext context) - { - foreach (T item in this) - OnAddEventHooks(item); - - OnDeserialized(); + // the events; } [NonSerialized] diff --git a/Source/Csla/Core/ManagedObjectBase.cs b/Source/Csla/Core/ManagedObjectBase.cs index bbdcb20efe..887fab51fa 100644 --- a/Source/Csla/Core/ManagedObjectBase.cs +++ b/Source/Csla/Core/ManagedObjectBase.cs @@ -6,10 +6,10 @@ // Base class for an object that is serializable //----------------------------------------------------------------------- +using System.ComponentModel; using System.Linq.Expressions; using System.Reflection; using Csla.Core.FieldManager; -using System.ComponentModel; using Csla.Reflection; using Csla.Serialization.Mobile; @@ -21,9 +21,9 @@ namespace Csla.Core /// [Serializable] public abstract class ManagedObjectBase : MobileObject, - INotifyPropertyChanged, + INotifyPropertyChanged, IManageProperties, - IUseApplicationContext, + IUseApplicationContext, IUseFieldManager { /// @@ -85,7 +85,7 @@ protected static PropertyInfo

RegisterProperty

(Type objectType, PropertyIn /// Type of property /// Property Expression /// The provided IPropertyInfo object. - protected static PropertyInfo

RegisterProperty(Expression> propertyLambdaExpression) + protected static PropertyInfo

RegisterProperty(Expression> propertyLambdaExpression) { PropertyInfo reflectedPropertyInfo = Reflect.GetProperty(propertyLambdaExpression); @@ -116,7 +116,7 @@ protected static PropertyInfo

RegisterProperty(ExpressionProperty Expression /// Friendly description for a property to be used in databinding /// The provided IPropertyInfo object. - protected static PropertyInfo

RegisterProperty(Expression> propertyLambdaExpression, string friendlyName) + protected static PropertyInfo

RegisterProperty(Expression> propertyLambdaExpression, string friendlyName) { PropertyInfo reflectedPropertyInfo = Reflect.GetProperty(propertyLambdaExpression); @@ -132,7 +132,7 @@ protected static PropertyInfo

RegisterProperty(ExpressionProperty Expression /// Friendly description for a property to be used in databinding /// Default Value for the property - protected static PropertyInfo

RegisterProperty(Expression> propertyLambdaExpression, string friendlyName, P defaultValue) + protected static PropertyInfo

RegisterProperty(Expression> propertyLambdaExpression, string friendlyName, P defaultValue) { PropertyInfo reflectedPropertyInfo = Reflect.GetProperty(propertyLambdaExpression); @@ -384,7 +384,7 @@ protected virtual bool LoadPropertyMarkDirty(IPropertyInfo propertyInfo, object var method = t.GetMethods(flags).FirstOrDefault(c => c.Name == "LoadPropertyMarkDirty" && c.IsGenericMethod); var gm = method.MakeGenericMethod(propertyInfo.Type); var p = new object[] { propertyInfo, newValue }; - return (bool) gm.Invoke(this, p); + return (bool)gm.Invoke(this, p); } #endregion @@ -459,28 +459,6 @@ protected override void OnSetChildren(SerializationInfo info, MobileFormatter fo #endregion - #region OnDeserialized - - - [System.Runtime.Serialization.OnDeserialized] - private void OnDeserializedHandler(System.Runtime.Serialization.StreamingContext context) - { - OnDeserialized(context); - } - - ///

- /// This method is called on a newly deserialized object - /// after deserialization is complete. - /// - /// Serialization context object. - [EditorBrowsable(EditorBrowsableState.Advanced)] - protected virtual void OnDeserialized(System.Runtime.Serialization.StreamingContext context) - { - FieldManager?.SetPropertyList(GetType()); - } - - #endregion - bool IManageProperties.FieldExists(IPropertyInfo property) => FieldManager.FieldExists(property); List IManageProperties.GetManagedProperties() => FieldManager.GetRegisteredProperties(); object IManageProperties.GetProperty(IPropertyInfo propertyInfo) => throw new NotImplementedException(); diff --git a/Source/Csla/Core/ObservableBindingList.cs b/Source/Csla/Core/ObservableBindingList.cs index 8671be71ec..41c3ca27e2 100644 --- a/Source/Csla/Core/ObservableBindingList.cs +++ b/Source/Csla/Core/ObservableBindingList.cs @@ -6,11 +6,11 @@ // Extends ObservableCollection with behaviors required //----------------------------------------------------------------------- -using System.ComponentModel; -using Csla.Serialization.Mobile; using System.Collections.Specialized; +using System.ComponentModel; using System.ComponentModel.DataAnnotations; using Csla.Properties; +using Csla.Serialization.Mobile; namespace Csla.Core { @@ -77,7 +77,7 @@ public bool AllowRemove ///
public bool RaiseListChangedEvents { - get { return _raiseListChangedEvents; } + get { return _raiseListChangedEvents; } set { _raiseListChangedEvents = value; } } @@ -359,32 +359,11 @@ protected virtual void OnRemoveEventHooks(T item) #region ISerializationNotification Members - /// - /// This method is called on a newly deserialized object - /// after deserialization is complete. - /// - [EditorBrowsable(EditorBrowsableState.Advanced)] - protected virtual void OnDeserialized() - { - // do nothing - this is here so a subclass - // could override if needed - } - - [System.Runtime.Serialization.OnDeserialized] - private void OnDeserializedHandler(System.Runtime.Serialization.StreamingContext context) - { - foreach (T item in this) - OnAddEventHooks(item); - - OnDeserialized(); - } - void ISerializationNotification.Deserialized() { // don't rehook events here, because the MobileFormatter has // created new objects and so the lists will auto-subscribe // the events - OnDeserialized(); } #endregion @@ -665,7 +644,7 @@ protected override void SetLoadListMode(bool enabled) else { if (_oldRLCE.Count > 0) - _raiseListChangedEvents = _oldRLCE.Pop(); + _raiseListChangedEvents = _oldRLCE.Pop(); } } } diff --git a/Source/Csla/DynamicBindingListBase.cs b/Source/Csla/DynamicBindingListBase.cs index 9a390fd1a8..573003c5ca 100644 --- a/Source/Csla/DynamicBindingListBase.cs +++ b/Source/Csla/DynamicBindingListBase.cs @@ -416,26 +416,6 @@ private PropertyDescriptor GetPropertyDescriptor(string propertyName) #endregion - #region Serialization Notification - - /// - /// This method is called on a newly deserialized object - /// after deserialization is complete. - /// - [EditorBrowsable(EditorBrowsableState.Advanced)] - protected override void OnDeserialized() - { - foreach (IEditableBusinessObject child in this) - { - child.SetParent(this); - if (child is INotifyPropertyChanged c) - c.PropertyChanged += Child_PropertyChanged; - } - base.OnDeserialized(); - } - - #endregion - #region Data Access private void DataPortal_Update() diff --git a/Source/Csla/DynamicListBase.cs b/Source/Csla/DynamicListBase.cs index 2be58cd44a..2f4109f99f 100644 --- a/Source/Csla/DynamicListBase.cs +++ b/Source/Csla/DynamicListBase.cs @@ -437,9 +437,9 @@ void IParent.RemoveChild(IEditableBusinessObject child) } - IParent IParent.Parent + IParent Csla.Core.IParent.Parent { - get { return null; } + get { return null; } } #endregion @@ -497,22 +497,6 @@ public override bool IsBusy } #endregion - #region Serialization Notification - - /// - /// Set parent reference. - /// - [EditorBrowsable(EditorBrowsableState.Advanced)] - protected override void OnDeserialized() - { - foreach (IEditableBusinessObject child in this) - child.SetParent(this); - - base.OnDeserialized(); - } - - #endregion - #region Data Access private void DataPortal_Update() diff --git a/Source/Csla/ReadOnlyBase.cs b/Source/Csla/ReadOnlyBase.cs index 26fe15ad1e..c07245b461 100644 --- a/Source/Csla/ReadOnlyBase.cs +++ b/Source/Csla/ReadOnlyBase.cs @@ -519,20 +519,8 @@ private void OnDeserializedHandler(System.Runtime.Serialization.StreamingContext if (_fieldManager != null) FieldManager.SetPropertyList(GetType()); InitializeBusinessRules(); - OnDeserialized(context); } - /// - /// This method is called on a newly deserialized object - /// after deserialization is complete. - /// - /// Serialization context object. - [EditorBrowsable(EditorBrowsableState.Advanced)] - protected virtual void OnDeserialized(System.Runtime.Serialization.StreamingContext context) - { - // do nothing - this is here so a subclass - // could override if needed - } #endregion