1
0
mirror of https://github.com/chylex/Backup-Essentials.git synced 2025-07-22 23:04:33 +02:00
Backup-Essentials/BackupEssentials/AppPageManager.cs
2015-04-03 14:21:09 +02:00

26 lines
709 B
C#

using System;
using System.Collections.Generic;
using System.Windows.Controls;
namespace BackupEssentials{
class AppPageManager{
private static Dictionary<Type,Page> cached = new Dictionary<Type,Page>();
public static T GetPage<T>() where T : Page, new(){
if (cached.ContainsKey(typeof(T)))return (T)cached[typeof(T)];
T page = new T();
cached[typeof(T)] = page;
return page;
}
public static Page GetPage(Type type){
if (cached.ContainsKey(type))return cached[type];
Page page = (Page)Activator.CreateInstance(type);
cached[type] = page;
return page;
}
}
}