using System;
namespace Nuclex.Windows.Forms {
/// Constructs views and view model in a scope
///
///
/// By default the uses its own
/// method to construct views
/// and view models via ,
/// which is enough to create forms (which the Windows Forms designer already
/// requires to have parameterless constructors) and view models, so long as
/// they also have parameterless constructors.
///
///
/// To support dependency injection via constructor parameters, you can
/// inherit from the and provide your own override
/// of that constructs the required
/// instance via your dependency injector. This is decent until you have multiple
/// view models all accessing the same resource (i.e. a database) via threads.
///
///
/// In this final case, "scopes" have become a common solution. Each
/// scope has access to singleton services (these exist for the lifetime of
/// the entire application), but there are also scoped services which will have
/// new instances constructed within each scope. By implementing the
/// method, you can make
/// the window manager set up an implicit scope per window or dialog.
///
///
public interface IWindowScope : IDisposable {
/// Creates an instance of the specified type in the scope
/// Type an instance will be created of
/// The created instance
///
/// Use this to wire up your dependency injection container. By default,
/// the Activator class will be used to create instances which only works
/// if all of your view models are concrete classes.
///
object CreateInstance(Type type);
}
} // namespace Nuclex.Windows.Forms