一、前言 保證一個類僅有一個實例,並提供一個該實例的全局訪問點。 二、代碼 ...
一、前言
保證一個類僅有一個實例,並提供一個該實例的全局訪問點。
二、代碼
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() { } }