From a6ad52d4920f94ef6091f5674520f2a6060369bb Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Thu, 10 Jan 2019 10:25:46 -0500 Subject: [PATCH] refactor: Removing log from ReflectionUtils.CreateInstance, doesn't make sense here --- ICD.Common.Utils/ReflectionUtils.cs | 31 +++++++---------------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/ICD.Common.Utils/ReflectionUtils.cs b/ICD.Common.Utils/ReflectionUtils.cs index a5b1ff6..e2a2ddf 100644 --- a/ICD.Common.Utils/ReflectionUtils.cs +++ b/ICD.Common.Utils/ReflectionUtils.cs @@ -4,8 +4,6 @@ using System.Linq; using ICD.Common.Properties; using ICD.Common.Utils.Extensions; using ICD.Common.Utils.IO; -using ICD.Common.Utils.Services; -using ICD.Common.Utils.Services.Logging; #if SIMPLSHARP using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharp.Reflection; @@ -170,6 +168,7 @@ namespace ICD.Common.Utils /// /// /// + [NotNull] public static Delegate CreateDelegate(Type type, object firstArgument, MethodInfo method) { return @@ -185,6 +184,7 @@ namespace ICD.Common.Utils /// Creates an instance of the given type, calling the default constructor. /// /// + [NotNull] public static T CreateInstance(Type type) { if (type == null) @@ -198,6 +198,7 @@ namespace ICD.Common.Utils /// /// /// + [NotNull] public static T CreateInstance(params object[] parameters) { if (parameters == null) @@ -210,6 +211,7 @@ namespace ICD.Common.Utils /// Creates an instance of the given type, calling the default constructor. /// /// + [NotNull] public static object CreateInstance(Type type, params object[] parameters) { if (type == null) @@ -218,28 +220,7 @@ namespace ICD.Common.Utils if (parameters == null) throw new ArgumentNullException("parameters"); - ConstructorInfo constructor = null; - - try - { - constructor = GetConstructor(type, parameters); - } - catch (ArgumentException e) - { - var logger = ServiceProvider.GetService(); - - logger.AddEntry(eSeverity.Error, "Could not find constructor while attempting to create instance."); - logger.AddEntry(eSeverity.Error, "Attempted to create an instance of type {0}", type.ToString()); - logger.AddEntry(eSeverity.Error, "With the following parameters:"); - foreach (var param in parameters) - { - logger.AddEntry(eSeverity.Error, "Type:{0}, Value:{1}", param.GetType().ToString(), param.ToString()); - } - logger.AddEntry(eSeverity.Error, "No valid constructor exists for this set of parameters."); - } - - if (constructor == null) - return null; + ConstructorInfo constructor = GetConstructor(type, parameters); try { @@ -289,6 +270,7 @@ namespace ICD.Common.Utils /// /// /// + [NotNull] public static Assembly LoadAssemblyFromPath(string path) { if (path == null) @@ -377,6 +359,7 @@ namespace ICD.Common.Utils /// The instance with the callback MethodInfo. Null for static types. /// The MethodInfo for the callback method. /// + [NotNull] public static Delegate SubscribeEvent(object instance, EventInfo eventInfo, object handler, MethodInfo callback) { if (eventInfo == null)