Dialog Factory
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