Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellabyte/1524380 to your computer and use it in GitHub Desktop.
Save kellabyte/1524380 to your computer and use it in GitHub Desktop.
public TViewModel ViewModel
{
get
{
TViewModel viewModel;
bool wasCreated;
bool designMode = DetectDesignMode();
if (designMode)
{
viewModel = new TDesignViewModel();
wasCreated = true;
}
else
{
if (shareInstances)
{
viewModel = (TViewModel)sharedInstances.CreateOrGetValue(
typeof(TViewModel),
() => new TViewModel(), out wasCreated);
}
else
{
viewModel = new TViewModel();
wasCreated = true;
}
}
viewModel.OnLocated(wasCreated);
return viewModel;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment