From adc59dbb4789ffe7905ddb17ecba4f7cfe7aa17a Mon Sep 17 00:00:00 2001 From: Jevon Date: Sat, 14 May 2022 09:22:37 +0100 Subject: [PATCH] Standardise null-or-empty checks, resolves deprecated `IsNullOrEmpty` helper method #612 - Updating Windsor to support Castle.Core@5.0.0 and modern TFMs --- .../Registration/ComponentRegistration.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Castle.Windsor/MicroKernel/Registration/ComponentRegistration.cs b/src/Castle.Windsor/MicroKernel/Registration/ComponentRegistration.cs index 06c5821c7a..0f4fe30d8a 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)