diff --git a/src/Castle.Windsor/MicroKernel/Registration/ComponentRegistration.cs b/src/Castle.Windsor/MicroKernel/Registration/ComponentRegistration.cs index 06c5821c7..0f4fe30d8 100644 --- a/src/Castle.Windsor/MicroKernel/Registration/ComponentRegistration.cs +++ b/src/Castle.Windsor/MicroKernel/Registration/ComponentRegistration.cs @@ -786,11 +786,11 @@ public ComponentRegistration NamedAutomatically(String name) /// A set of actions to be executed right after the component is created and before it's returned from the container. public ComponentRegistration OnCreate(params Action[] actions) { - if (actions.IsNullOrEmpty()) + if (actions != null && actions.Length != 0) { - return this; + return OnCreate(actions.ConvertAll(a => new LifecycleActionDelegate((_, o) => a(o)))); } - return OnCreate(actions.ConvertAll(a => new LifecycleActionDelegate((_, o) => a(o)))); + return this; } /// @@ -813,16 +813,16 @@ public ComponentRegistration OnCreate(params LifecycleActionDelegate A set of actions to be executed right after the component is created and before it's returned from the container. public ComponentRegistration OnDestroy(params Action[] actions) { - if (actions.IsNullOrEmpty()) + if (actions != null && actions.Length != 0) { - return this; + return OnDestroy(actions.ConvertAll(a => new LifecycleActionDelegate((_, o) => a(o)))); } - return OnDestroy(actions.ConvertAll(a => new LifecycleActionDelegate((_, o) => a(o)))); + return this; } /// /// Stores a set of which will be invoked when the component is destroyed which means when it's released or it's lifetime scope ends. Notice that usage of this - /// method will cause instsances of the component to be tracked, even if they wouldn't be otherwise. + /// method will cause instances of the component to be tracked, even if they wouldn't be otherwise. /// /// A set of actions to be executed when the component is destroyed. public ComponentRegistration OnDestroy(params LifecycleActionDelegate[] actions)