/// <summary> /// Create a new instance of the ToolbarExtensionManager. This class is /// private and will be called internally by the InitialSetup method. /// </summary> /// <param name="_parentToolbar">The viewmodel for the toolbar being managed</param> /// <param name="_scope">The scope of the data that the tool bar items will have /// access too</param> private ToolbarExtensionManager(ToolbarViewModel _parentToolbar, string _scope) { this.parentToolbar = _parentToolbar; this.scope = _scope; }
/// <summary> /// Provides a deterministic way to create the ToolbarVMStatic property /// </summary> public static void CreateToolbarVM() { if (toolbarVM == null) { toolbarVM = new ToolbarViewModel(); } }
/// <summary> /// Performs the initial setup of the ToolbarExtensionManager. This method /// must be called once before the Instance property can be used. /// </summary> /// <param name="_parentToolbar"></param> /// <param name="_scope"></param> public static void InitialSetup(ToolbarViewModel _parentToolbar, string _scope) { // Validate parameters if (_parentToolbar == null) throw new System.ArgumentNullException("_parentToolPanel", "An invalid ToolPanelViewModel was provided"); if (string.IsNullOrEmpty(_scope)) throw new System.ArgumentNullException("_scope", "An invalid scope was provided"); lock (syncRoot) { // Ensure that this can only be called once if (instance == null) { instance = new ToolbarExtensionManager(_parentToolbar, _scope); ExtensionManager.ComposeParts(instance); } } }
/// <summary> /// Provides a deterministic way to delete the ToolbarVMStatic property /// </summary> public static void ClearToolbarVM() { toolbarVM.Cleanup(); toolbarVM = null; }