Skip to content

Instantly share code, notes, and snippets.

@r4hulp r4hulp/DialogFactory.cs
Last active Dec 29, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.