Last active
December 29, 2017 12:19
-
-
Save r4hulp/ae7e4fc02f501e245325d9b1fc52d282 to your computer and use it in GitHub Desktop.
Dialog Factory
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
public interface IDialogFactory | |
{ | |
//constructor without dynamic params | |
T Create<T>(); | |
//Constructor requiring multiple dynamic params | |
T Create<T>(IDictionary<string, object> parameters); | |
} | |
public class DialogFactory : IDialogFactory | |
{ | |
protected readonly IComponentContext Scope; | |
//IComponentContext does not need to be registered as Autofac automatically provides it. | |
public DialogFactory(IComponentContext scope) | |
{ | |
SetField.NotNull(out this.Scope, nameof(scope), scope); | |
} | |
public T Create<T>() | |
{ | |
return this.Scope.Resolve<T>(); | |
} | |
public T Create<T>(IDictionary<string, object> parameters) | |
{ | |
return this.Scope.Resolve<T>(parameters.Select(kv => new NamedParameter(kv.Key, kv.Value))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment