private void LogError(string message) { IConfigurationErrorLogService logService = ServiceHelper.GetConfigurationErrorService(ServiceProvider); IUIHierarchyService uiHierarchyService = ServiceHelper.GetUIHierarchyService(ServiceProvider); logService.LogError(new ConfigurationError(uiHierarchyService.SelectedHierarchy.RootNode, message)); }
/// <summary> /// <para>Log a <see cref="ConfigurationError"/> to the <see cref="IConfigurationErrorLogService"/>.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> /// <param name="error"> /// <para>The <see cref="ConfigurationError"/> to log.</para> /// </param> public static void LogError(IServiceProvider serviceProvider, ConfigurationError error) { ArgumentValidation.CheckForNullReference(error, "error"); IConfigurationErrorLogService configurationErrorLogService = GetConfigurationErrorService(serviceProvider); configurationErrorLogService.LogError(error); }
/// <summary> /// <para>Gets the registered <see cref="IConfigurationErrorLogService"/>.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> /// <returns> /// <para>The registered <see cref="IConfigurationErrorLogService"/>.</para> /// </returns> public static IConfigurationErrorLogService GetConfigurationErrorService(IServiceProvider serviceProvider) { ArgumentValidation.CheckForNullReference(serviceProvider, "serviceProvider"); IConfigurationErrorLogService errorLogService = serviceProvider.GetService(typeof(IConfigurationErrorLogService)) as IConfigurationErrorLogService; Debug.Assert(errorLogService != null, "Could not get the IConfigurationErrorLogService"); return(errorLogService); }
public void MinLengthViolationTestWithVistor() { ValidateNodeCommand cmd = new ValidateNodeCommand(Host); Assert.IsNotNull(minLengthNode.Site); IConfigurationErrorLogService configurationErrorLogService = minLengthNode.Site.GetService(typeof(IConfigurationErrorLogService)) as IConfigurationErrorLogService; Assert.IsNotNull(configurationErrorLogService); cmd.Execute(minLengthNode); Assert.AreEqual(2, ValidationErrorsCount); }
/// <summary> /// <para>Save the application and all it's configuration.</para> /// </summary> public void Save() { this.configDomain.Save(); IConfigurationErrorLogService errorLogService = serviceProvider.GetService(typeof(IConfigurationErrorLogService)) as IConfigurationErrorLogService; Debug.Assert(errorLogService != null); if (errorLogService.ConfigurationErrors.Count > 0) { return; } OnSaved(new HierarchySavedEventArgs(this)); }
public void DisplayErrorLog(IConfigurationErrorLogService errorLogService) { foreach (ValidationError error in errorLogService.ValidationErrors) { Trace.WriteLine("DisplayValidationErrors:" + error.Message); } fixture.validationErrorsCount = errorLogService.ValidationErrors.Count; foreach (ConfigurationError error in errorLogService.ConfigurationErrors) { Trace.WriteLine("DisplayConfigurationErrors:" + error.Message); } fixture.configurationErrorsCount = errorLogService.ConfigurationErrors.Count; }
public virtual void SetUp() { host = new ConfigurationDesignHost(); hierarchyService = (IUIHierarchyService)host.GetService(typeof(IUIHierarchyService)); configurationErrorLogService = (IConfigurationErrorLogService)host.GetService(typeof(IConfigurationErrorLogService)); xmlIncludeTypeService = (IXmlIncludeTypeService)host.GetService(typeof(IXmlIncludeTypeService)); nodeCreationService = (INodeCreationService)host.GetService(typeof(INodeCreationService)); container = (IContainer)host.GetService(typeof(IContainer)); linkNodeService = (ILinkNodeService)host.GetService(typeof(ILinkNodeService)); host.AddService(typeof(IUIService), new MyUIService(this)); validationErrorsCount = 0; configurationErrorsCount = 0; applicationNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain()); uiHierarchy = CreateHierarchyAndAddToHierarchyService(applicationNode, CreateDefaultConfiguration()); }
/// <devdoc> /// Invokes IConfigurationDesignManager.Register on all of the contained IConfigurationDesignManager objects. /// </devdoc> internal void Register() { foreach (IConfigurationDesignManager manager in managers) { try { manager.Register(serviceProvider); } catch (IOException e) { IUIHierarchyService uiHiearchyService = serviceProvider.GetService(typeof(IUIHierarchyService)) as IUIHierarchyService; Debug.Assert(uiHiearchyService != null, "Could not load the IUIHiearchyService."); IConfigurationErrorLogService configurationErrorLogService = serviceProvider.GetService(typeof(IConfigurationErrorLogService)) as IConfigurationErrorLogService; Debug.Assert(configurationErrorLogService != null, "Could not load the IErrorService."); configurationErrorLogService.LogError(new ConfigurationError(uiHiearchyService.SelectedHierarchy.SelectedNode, e.Message)); } } }
/// <summary> /// <para>Determines if the current <see cref="FileName"/> can be overwrriten. It will prompt the user throuth the user interface if the user wants to overwrite the file.</para> /// </summary> /// <returns> /// <para><see langword="true"/> if the file can be overwritten; otherwise, <see langword="false"/>.</para> /// </returns> protected bool CanOverwriteFile() { if (FileHelper.IsFileReadOnly(fileName)) { IUIService uiService = ServiceHelper.GetUIService(ServiceProvider); DialogResult result = uiService.ShowMessage(SR.OverwriteFileMessage(fileName), SR.OverwriteFileCaption, System.Windows.Forms.MessageBoxButtons.YesNo); if (DialogResult.Yes == result) { FileHelper.ChangeFileAttributesToWritable(fileName); } else { IConfigurationErrorLogService logService = ServiceHelper.GetConfigurationErrorService(ServiceProvider); logService.LogError(new ConfigurationError(null, SR.ExceptionFilesNotSaved)); return(false); } } return(true); }
public void AssertCanGetAllServices() { IContainer container = Host.GetService(typeof(IContainer)) as IContainer; Assert.IsNotNull(container); IComponentChangeService changeService = Host.GetService(typeof(IComponentChangeService)) as IComponentChangeService; Assert.IsNotNull(changeService); INodeNameCreationService nodeNameCreationService = Host.GetService(typeof(INodeNameCreationService)) as INodeNameCreationService; Assert.IsNotNull(nodeNameCreationService); INameCreationService nameCreationService = Host.GetService(typeof(INameCreationService)) as INameCreationService; Assert.IsNotNull(nameCreationService); IUIHierarchyService hierarchyService = Host.GetService(typeof(IUIHierarchyService)) as IUIHierarchyService; Assert.IsNotNull(hierarchyService); IDictionaryService dictionaryService = Host.GetService(typeof(IDictionaryService)) as IDictionaryService; Assert.IsNotNull(dictionaryService); IConfigurationErrorLogService configurationErrorLogService = Host.GetService(typeof(IConfigurationErrorLogService)) as IConfigurationErrorLogService; Assert.IsNotNull(configurationErrorLogService); INodeCreationService nodeCreationService = Host.GetService(typeof(INodeCreationService)) as INodeCreationService; Assert.IsNotNull(nodeCreationService); IXmlIncludeTypeService xmlIncludeTypeService = Host.GetService(typeof(IXmlIncludeTypeService)) as IXmlIncludeTypeService; Assert.IsNotNull(xmlIncludeTypeService); ILinkNodeService linkNodeService = Host.GetService(typeof(ILinkNodeService)) as ILinkNodeService; Assert.IsNotNull(linkNodeService); IMenuContainerService menuContainerService = Host.GetService(typeof(IMenuContainerService)) as IMenuContainerService; Assert.IsNotNull(menuContainerService); }
public void DisplayErrorLog(IConfigurationErrorLogService errorLogService) { ResetErrorList(); foreach (ValidationError validationError in errorLogService.ValidationErrors) { UpdateTreeNode((ConfigurationNode)validationError.InvalidObject); errorsListView.Items.Add(new ValidationErrorListViewItem(validationError)); } foreach (ConfigurationError configurationError in errorLogService.ConfigurationErrors) { UpdateTreeNode(configurationError.ConfigurationNode); errorsListView.Items.Add(new ConfigurationErrorListViewItem(configurationError)); } }