Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/remove on deserialized #3955

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
760e17b
Updated ISessionManager and SessionManager with timeout and cancellat…
luizbicalhoagl May 1, 2024
d54e552
`Refactor SessionManager and StateManager for improved session handling`
luizbicalhoagl May 1, 2024
911eb96
Refactor SessionManagerTests and remove certain test methods
luizbicalhoagl May 1, 2024
2b35219
Refactor SessionManager and update related tests
luizbicalhoagl May 2, 2024
d648d77
Merge branch 'main' into main
luizfbicalho May 3, 2024
33a0c17
`Convert SaveState to async in StateManager.cs`
luizbicalhoagl May 3, 2024
8e4617b
Merge branch 'main' of https://github.com/luizfbicalho/csla
luizbicalhoagl May 3, 2024
74ffc4c
`Update packages, refactor code, add tests, and remove project`
luizbicalhoagl May 3, 2024
ce84444
Updated SessionManager and its tests for async operations and better …
luizbicalhoagl May 4, 2024
73e9986
Subject: Refactored test methods and updated session retrieval
luizbicalhoagl May 4, 2024
5f59d4a
Refactor variable names to follow C# naming convention
luizbicalhoagl May 4, 2024
d9201aa
Merge branch 'main' into main
rockfordlhotka May 6, 2024
b6c01b9
Switch from Moq to NSubstitute in Csla.Blazor.WebAssembly.Tests
luizbicalhoagl May 7, 2024
76c6b75
Merge branch 'main' of https://github.com/luizfbicalho/csla
luizbicalhoagl May 7, 2024
57c3c5b
Merge branch 'main' into main
luizfbicalho May 7, 2024
98bc9e4
Merge branch 'MarimerLLC:main' into main
luizfbicalho May 11, 2024
0eb640f
Merge branch 'MarimerLLC:main' into main
luizfbicalho May 16, 2024
2b5ed27
Merge branch 'MarimerLLC:main' into main
luizfbicalho May 18, 2024
72454d8
Merge branch 'main' of https://github.com/luizfbicalho/csla
luizbicalhoagl May 19, 2024
97ddc29
Refactored code for readability and modified deserialization process
luizbicalhoagl May 19, 2024
410d2ce
Merge branch 'MarimerLLC:main' into main
luizfbicalho May 21, 2024
df149e3
Merge branch 'MarimerLLC:main' into main
luizfbicalho May 21, 2024
4db5841
merge from main
luizbicalhoagl May 21, 2024
712a854
Merge branch 'MarimerLLC:main' into main
luizfbicalho May 24, 2024
a926603
Merge branch 'MarimerLLC:main' into main
luizfbicalho May 25, 2024
26873f2
merge from main
luizbicalhoagl May 25, 2024
8e4822a
Merge branch 'main' into feature/RemoveOnDeserialized
luizfbicalho May 26, 2024
c792c48
Merge branch 'main' into feature/RemoveOnDeserialized
rockfordlhotka Jun 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 1 addition & 28 deletions Source/Csla/BusinessBindingListBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -861,33 +861,6 @@ bool ITrackStatus.IsDeleted

#endregion

#region Serialization Notification

[NonSerialized]
[NotUndoable]
private bool _deserialized = false;

/// <summary>
/// This method is called on a newly deserialized object
/// after deserialization is complete.
/// </summary>
[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

/// <summary>
Expand Down Expand Up @@ -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++)
{
Expand Down
19 changes: 0 additions & 19 deletions Source/Csla/BusinessListBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,6 @@ private void AcceptChanges(int parentEditLevel)
if (child.EditLevelAdded > EditLevel)
DeletedList.RemoveAt(index);
}

if (EditLevel < 0) EditLevel = 0;
}

Expand Down Expand Up @@ -883,24 +882,6 @@ bool ITrackStatus.IsDeleted

#endregion

#region Serialization Notification

/// <summary>
/// Reset parent references on deserialization.
/// </summary>
[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

/// <summary>
Expand Down
23 changes: 1 addition & 22 deletions Source/Csla/Core/ExtendedBindingList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,32 +249,11 @@ protected virtual void OnRemoveEventHooks(T item)
child.ChildChanged -= Child_Changed;
}

/// <summary>
/// This method is called on a newly deserialized object
/// after deserialization is complete.
/// </summary>
[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]
Expand Down
36 changes: 7 additions & 29 deletions Source/Csla/Core/ManagedObjectBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
// <summary>Base class for an object that is serializable</summary>
//-----------------------------------------------------------------------

using System.ComponentModel;
using System.Linq.Expressions;
using System.Reflection;
using Csla.Core.FieldManager;
using System.ComponentModel;
using Csla.Reflection;
using Csla.Serialization.Mobile;

Expand All @@ -21,9 +21,9 @@ namespace Csla.Core
/// </summary>
[Serializable]
public abstract class ManagedObjectBase : MobileObject,
INotifyPropertyChanged,
INotifyPropertyChanged,
IManageProperties,
IUseApplicationContext,
IUseApplicationContext,
IUseFieldManager
{
/// <summary>
Expand Down Expand Up @@ -85,7 +85,7 @@ protected static PropertyInfo<P> RegisterProperty<P>(Type objectType, PropertyIn
/// <typeparam name="P">Type of property</typeparam>
/// <param name="propertyLambdaExpression">Property Expression</param>
/// <returns>The provided IPropertyInfo object.</returns>
protected static PropertyInfo<P> RegisterProperty<T,P>(Expression<Func<T, object>> propertyLambdaExpression)
protected static PropertyInfo<P> RegisterProperty<T, P>(Expression<Func<T, object>> propertyLambdaExpression)
{
PropertyInfo reflectedPropertyInfo = Reflect<T>.GetProperty(propertyLambdaExpression);

Expand Down Expand Up @@ -116,7 +116,7 @@ protected static PropertyInfo<P> RegisterProperty<T, P>(Expression<Func<T, objec
/// <param name="propertyLambdaExpression">Property Expression</param>
/// <param name="friendlyName">Friendly description for a property to be used in databinding</param>
/// <returns>The provided IPropertyInfo object.</returns>
protected static PropertyInfo<P> RegisterProperty<T,P>(Expression<Func<T, object>> propertyLambdaExpression, string friendlyName)
protected static PropertyInfo<P> RegisterProperty<T, P>(Expression<Func<T, object>> propertyLambdaExpression, string friendlyName)
{
PropertyInfo reflectedPropertyInfo = Reflect<T>.GetProperty(propertyLambdaExpression);

Expand All @@ -132,7 +132,7 @@ protected static PropertyInfo<P> RegisterProperty<T,P>(Expression<Func<T, object
/// <param name="propertyLambdaExpression">Property Expression</param>
/// <param name="friendlyName">Friendly description for a property to be used in databinding</param>
/// <param name="defaultValue">Default Value for the property</param>
protected static PropertyInfo<P> RegisterProperty<T,P>(Expression<Func<T, object>> propertyLambdaExpression, string friendlyName, P defaultValue)
protected static PropertyInfo<P> RegisterProperty<T, P>(Expression<Func<T, object>> propertyLambdaExpression, string friendlyName, P defaultValue)
{
PropertyInfo reflectedPropertyInfo = Reflect<T>.GetProperty(propertyLambdaExpression);

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

/// <summary>
/// This method is called on a newly deserialized object
/// after deserialization is complete.
/// </summary>
/// <param name="context">Serialization context object.</param>
[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<IPropertyInfo> IManageProperties.GetManagedProperties() => FieldManager.GetRegisteredProperties();
object IManageProperties.GetProperty(IPropertyInfo propertyInfo) => throw new NotImplementedException();
Expand Down
29 changes: 4 additions & 25 deletions Source/Csla/Core/ObservableBindingList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// <summary>Extends ObservableCollection with behaviors required</summary>
//-----------------------------------------------------------------------

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
{
Expand Down Expand Up @@ -77,7 +77,7 @@ public bool AllowRemove
/// </summary>
public bool RaiseListChangedEvents
{
get { return _raiseListChangedEvents; }
get { return _raiseListChangedEvents; }
set { _raiseListChangedEvents = value; }
}

Expand Down Expand Up @@ -359,32 +359,11 @@ protected virtual void OnRemoveEventHooks(T item)

#region ISerializationNotification Members

/// <summary>
/// This method is called on a newly deserialized object
/// after deserialization is complete.
/// </summary>
[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
Expand Down Expand Up @@ -665,7 +644,7 @@ protected override void SetLoadListMode(bool enabled)
else
{
if (_oldRLCE.Count > 0)
_raiseListChangedEvents = _oldRLCE.Pop();
_raiseListChangedEvents = _oldRLCE.Pop();
}
}
}
Expand Down
20 changes: 0 additions & 20 deletions Source/Csla/DynamicBindingListBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,26 +416,6 @@ private PropertyDescriptor GetPropertyDescriptor(string propertyName)

#endregion

#region Serialization Notification

/// <summary>
/// This method is called on a newly deserialized object
/// after deserialization is complete.
/// </summary>
[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()
Expand Down
20 changes: 2 additions & 18 deletions Source/Csla/DynamicListBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,9 @@ void IParent.RemoveChild(IEditableBusinessObject child)
}


IParent IParent.Parent
IParent Csla.Core.IParent.Parent
{
get { return null; }
get { return null; }
}

#endregion
Expand Down Expand Up @@ -497,22 +497,6 @@ public override bool IsBusy
}
#endregion

#region Serialization Notification

/// <summary>
/// Set parent reference.
/// </summary>
[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()
Expand Down
12 changes: 0 additions & 12 deletions Source/Csla/ReadOnlyBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -519,20 +519,8 @@ private void OnDeserializedHandler(System.Runtime.Serialization.StreamingContext
if (_fieldManager != null)
FieldManager.SetPropertyList(GetType());
InitializeBusinessRules();
OnDeserialized(context);
}

/// <summary>
/// This method is called on a newly deserialized object
/// after deserialization is complete.
/// </summary>
/// <param name="context">Serialization context object.</param>
[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

Expand Down
Loading