App.xaml.cs 885 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace Install
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
潘栩锋's avatar
潘栩锋 committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
        public static T Resolve<T>()
        {
            return (T)App.Current.Properties[typeof(T).FullName];
        }
        public static T Resolve<T>(string name)
        {
            return (T)App.Current.Properties[typeof(T).FullName + $".{name}"];
        }
        public static void RegisterInstance<T>(T obj)
        {
            App.Current.Properties[typeof(T).FullName] = obj;
        }
        public static void RegisterInstance<T>(T obj, string name)
        {
            App.Current.Properties[typeof(T).FullName + $".{name}"] = obj;
        }
32 33
    }
}