一、前言
保证一个类仅有一个实例,并提供一个该实例的全局访问点。
二、代码
public class ApplicationServices { public static readonly Lazy<ApplicationServices> ServicesInstance = new Lazy<ApplicationServices>(() => new ApplicationServices()); //Lazy加载 private ProjectSettingManager _projectManager; public ProjectSettingManager ProjectManager { get { return _projectManager; } public static ApplicationServices Instance { get { return ServicesInstance.Value; } } public ApplicationServices() { } }