Index: src/Common/DelftTools.Utils/Aop/EditActionAttribute.cs =================================================================== diff -u -rd23256baec33c7a1da86a6378f1146a55640f757 -r5fc71a385897af92ccb092f2f969b5709afab85a --- src/Common/DelftTools.Utils/Aop/EditActionAttribute.cs (.../EditActionAttribute.cs) (revision d23256baec33c7a1da86a6378f1146a55640f757) +++ src/Common/DelftTools.Utils/Aop/EditActionAttribute.cs (.../EditActionAttribute.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a) @@ -14,23 +14,10 @@ [Synchronization] public class EditActionAttribute : MethodInterceptionAspect { - public EditActionAttribute() - { - } + public static event Action BeforeEdit; - private readonly Type editActionType; + public static event Action AfterEdit; - public EditActionAttribute(Type editActionType) - { - if (!(typeof(IEditAction).IsAssignableFrom(editActionType))) - { - throw new ArgumentException(string.Format("Type {0} is not of type IEditAction", - editActionType)); - } - - this.editActionType = editActionType; - } - /// /// Fired before any CollectionChanging or PropertyChanging events occur. /// @@ -40,22 +27,23 @@ /// Fired after any CollectionChanged or PropertyChanged events occur. When collection Changing is cancelled - this event is still fired. /// public static Action AfterEventCall; - - public static event Action BeforeEdit; - public static event Action AfterEdit; - [ThreadStatic] private static int editActionsInProgress; - internal static string Indent - { - get { return GetIndent(editActionsInProgress); } - } + private readonly Type editActionType; - private static string GetIndent(int num) + public EditActionAttribute() {} + + public EditActionAttribute(Type editActionType) { - return Enumerable.Repeat(" ", Math.Max(0, num)).Aggregate("", (s1, s2) => s1 + s2); + if (!(typeof(IEditAction).IsAssignableFrom(editActionType))) + { + throw new ArgumentException(string.Format("Type {0} is not of type IEditAction", + editActionType)); + } + + this.editActionType = editActionType; } public static void FireBeforeEventCall(object sender, bool isPropertyChange) @@ -80,7 +68,7 @@ } } - public sealed override void OnInvoke(MethodInterceptionArgs eventArgs) + public override sealed void OnInvoke(MethodInterceptionArgs eventArgs) { if (EditActionSettings.Disabled && !(EditActionSettings.AllowRestoreActions && editActionType != null)) { @@ -95,7 +83,7 @@ if (EventSettings.EnableLogging) { //log.DebugFormat(Indent + ">> Entering edit action {0} (enabled:{1}) {2}", - // (eventArgs.Instance != null ? eventArgs.Instance.GetType().Name : "static") + "." + eventArgs.Method.Name, !Disabled, editActionsInProgress); + // (eventArgs.Instance != null ? eventArgs.Instance.GetType().Name : "static") + "." + eventArgs.Method.Name, !Disabled, editActionsInProgress); } if (BeforeEdit != null) @@ -128,10 +116,10 @@ { eventArgs.Proceed(); } - catch(Exception) + catch (Exception) { exception = true; - + throw; } finally @@ -169,6 +157,19 @@ editActionsInProgress--; } } + + internal static string Indent + { + get + { + return GetIndent(editActionsInProgress); + } + } + + private static string GetIndent(int num) + { + return Enumerable.Repeat(" ", Math.Max(0, num)).Aggregate("", (s1, s2) => s1 + s2); + } } /// @@ -180,5 +181,4 @@ public static bool AllowRestoreActions; public static bool SupportEditableObject; } - -} +} \ No newline at end of file