using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace Install
{
///
/// App.xaml 的交互逻辑
///
public partial class App : Application
{
public App()
{
AppDomain.CurrentDomain.UnhandledException += (s, e) =>
{
MessageBox.Show("程序出现异常,请把下面信息拍照发给厂家" + Environment.NewLine + e.ExceptionObject.ToString(),
"异常,联系厂家",
MessageBoxButton.OK, MessageBoxImage.Error);
};
}
public static T Resolve()
{
return (T)App.Current.Properties[typeof(T).FullName];
}
public static T Resolve(string name)
{
return (T)App.Current.Properties[typeof(T).FullName + $".{name}"];
}
public static void RegisterInstance(T obj)
{
App.Current.Properties[typeof(T).FullName] = obj;
}
public static void RegisterInstance(T obj, string name)
{
App.Current.Properties[typeof(T).FullName + $".{name}"] = obj;
}
}
}