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