From 02652a58d40f8f3a2484dea52cfb38a936d92442 Mon Sep 17 00:00:00 2001 From: dicky Date: Thu, 7 Dec 2017 17:47:57 -0800 Subject: [PATCH] Added RegisterAssembly overload. --- DotNetifyLib.Core/DotNetifyConfiguration.cs | 11 ++++++++--- DotNetifyLib.Core/VMController.Registration.cs | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/DotNetifyLib.Core/DotNetifyConfiguration.cs b/DotNetifyLib.Core/DotNetifyConfiguration.cs index 1dd8b35c..86c7d860 100644 --- a/DotNetifyLib.Core/DotNetifyConfiguration.cs +++ b/DotNetifyLib.Core/DotNetifyConfiguration.cs @@ -39,12 +39,12 @@ public class DotNetifyConfiguration : IDotNetifyConfiguration /// /// Register view model classes in an assembly that are subtypes of BaseVM. /// - public void RegisterAssembly(Assembly assembly) => VMController.RegisterAssembly(assembly); + public void RegisterAssembly(Assembly assembly) => VMController.RegisterAssembly(assembly); /// /// Register view model classes in an assembly that are subtypes of BaseVM. /// - public void RegisterAssembly(string assemblyName) => VMController.RegisterAssembly(Assembly.Load(new AssemblyName(assemblyName))); + public void RegisterAssembly(string assemblyName) => VMController.RegisterAssembly(Assembly.Load(new AssemblyName(assemblyName))); /// /// Register view model classes in an assembly that are subtypes of a certain type. @@ -79,7 +79,12 @@ public IDotNetifyConfiguration Register(string typeName, Func /// Registers view model classes in the entry assembly. /// - public void RegisterEntryAssembly() => VMController.RegisterAssembly(Assembly.GetEntryAssembly()); + public void RegisterEntryAssembly() + { + var entryAssembly = Assembly.GetEntryAssembly(); + if (entryAssembly != null) + VMController.RegisterAssembly(entryAssembly); + } /// /// Whether anything has been registered. diff --git a/DotNetifyLib.Core/VMController.Registration.cs b/DotNetifyLib.Core/VMController.Registration.cs index 6146660b..55cbc59c 100644 --- a/DotNetifyLib.Core/VMController.Registration.cs +++ b/DotNetifyLib.Core/VMController.Registration.cs @@ -51,6 +51,12 @@ public partial class VMController #endregion + /// + /// Registers all view model types in an assembly. + /// + /// Assembly. + public static void RegisterAssembly(Assembly vmAssembly) => RegisterAssembly(vmAssembly); + /// /// Registers all view model types in an assembly. ///