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 class MainViewModelFactory | |
: ViewModelFactory<MainViewModel, MainViewModelDesign> | |
{ | |
} | |
/// <summary> | |
/// Design time version of the MainViewModel. | |
/// </summary> | |
public class MainViewModelDesign : MainViewModel | |
{ |
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 class MainViewModelFactory | |
: ViewModelFactory<MainViewModel, MainViewModelDesign> | |
{ | |
} | |
public class MainViewModelDesign : MainViewModel | |
{ | |
public MainViewModelDesign() | |
: base(new EventAggregator(), new DesignDatabase()) | |
{ |
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 class DesignDatabase : IDatabase | |
{ | |
public Feed GetFeed() | |
{ | |
return new Feed(); | |
} | |
public void SaveFeed(Feed feed) | |
{ | |
} |
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
private void InitApplicationHost() | |
{ | |
events = new EventAggregator(); | |
db = new Database(); | |
ApplicationHost.Current.Container.Register<EventAggregator>(events); | |
ApplicationHost.Current.Container.Register<Database>(db); | |
} |
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
private void InitApplicationHost() | |
{ | |
var container = ApplicationHost.Current.Container; | |
db = new Database(); | |
container.Register<IEventAggregator>(new EventAggregator()); | |
container.Register<IDatabase>(db); | |
container.Register<MainViewModel>(c => new MainViewModel( |
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 class ApplicationHost | |
{ | |
private static volatile ApplicationHost instance; | |
private static object syncRoot = new Object(); | |
private ApplicationHost() | |
{ | |
Execute.InitializeWithDispatcher(); | |
// Initialize the Funq container. |
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 class Bootstrapper | |
{ | |
private Container container = null; | |
public Bootstrapper() | |
{ | |
Initialize(); | |
} | |
private void Initialize() |
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 IViewModelResolver | |
{ | |
IViewModel Resolve(); | |
} | |
public class FunqViewModelResolver : IViewModelResolver | |
{ | |
private readonly Container container; | |
private Dictionary<type , MethodInfo> methods = null; | |
private MethodInfo method = null; |
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 abstract class ViewModelFactory<TViewModel, TDesignViewModel> | |
where TViewModel : IViewModel | |
where TDesignViewModel : TViewModel, new() | |
{ | |
public ViewModelFactory() | |
{ | |
} | |
public TViewModel ViewModel | |
{ |
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 abstract class ViewModelFactory | |
{ | |
protected static IViewModelResolver resolver = null; | |
public static void InitializeResolver(IViewModelResolver resolver) | |
{ | |
// This is where we set the resolver for the ViewModelFactory. | |
// This should get set in the Bootstrapper (Composition Root) | |
// to the resolver implementation using the | |
// IoC container that has been chosen for the application. | |
ViewModelFactory.resolver = resolver; |