forked from dsuryd/dotNetify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added IDotNetifyConfiguration to simplify startup config.
Dicky Suryadi
committed
Feb 16, 2017
1 parent
3b11762
commit fdf75de
Showing
6 changed files
with
108 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace DotNetify | ||
{ | ||
public interface IDotNetifyConfiguration | ||
{ | ||
/// <summary> | ||
/// Provides a factory method to create view model instances. | ||
/// The method accepts a class type and constructor arguments, and returns an instance of that type. | ||
/// </summary> | ||
void SetFactoryMethod(Func<Type, object[], object> factoryMethod); | ||
|
||
/// <summary> | ||
/// Register an assembly that has the view model classes. | ||
/// </summary> | ||
void RegisterAssembly(Assembly assembly); | ||
void RegisterAssembly(string assemblyName); | ||
} | ||
|
||
public class DotNetifyConfiguration : IDotNetifyConfiguration | ||
{ | ||
public void SetFactoryMethod(Func<Type, object[], object> factoryMethod) => VMController.CreateInstance = (type, args) => factoryMethod(type, args); | ||
|
||
public void RegisterAssembly(Assembly assembly) => VMController.RegisterAssembly(assembly); | ||
|
||
public void RegisterAssembly(string assemblyName) => VMController.RegisterAssembly(Assembly.Load(new AssemblyName(assemblyName))); | ||
|
||
public void RegisterEntryAssembly() => VMController.RegisterAssembly(Assembly.GetEntryAssembly()); | ||
|
||
public bool HasAssembly => VMController._registeredAssemblies.Count > 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters