protected override void ExecuteCore(ConfigurationNode node)
        {
            TypeSelectorUI selector = new TypeSelectorUI(
                typeof(RijndaelManaged),
                typeof(SymmetricAlgorithm),
                TypeSelectorIncludeFlags.Default
                );
            DialogResult typeResult = selector.ShowDialog();
            if (typeResult == DialogResult.OK)
            {
                KeySettings keySettings = new KeySettings(new SymmetricAlgorithmKeyCreator(selector.SelectedType.AssemblyQualifiedName));
                KeyManagerEditorUI keyManager = new KeyManagerEditorUI(keySettings);
                DialogResult keyResult = keyManager.ShowDialog();

                if (keyResult == DialogResult.OK)
                {
                    INodeNameCreationService service = GetService(typeof(INodeNameCreationService)) as INodeNameCreationService;
                    Debug.Assert(service != null, "Could not find the INodeNameCreationService");
                    base.ExecuteCore(node);
                    SymmetricAlgorithmProviderNode providerNode = (SymmetricAlgorithmProviderNode)ChildNode;
                    providerNode.AlgorithmType = selector.SelectedType.AssemblyQualifiedName;
                    providerNode.Name = service.GetUniqueDisplayName(providerNode.Parent, selector.SelectedType.Name);
                    providerNode.Key = keyManager.KeySettings;
                }
            }
        }
        private bool TryAndSaveApplication(ConfigurationNode node)
        {
            SaveApplicationConfigurationNodeCommand cmd = new SaveApplicationConfigurationNodeCommand(ServiceProvider);

            cmd.Execute(node);
            return(cmd.SaveSucceeded);
        }
 /// <summary>
 /// <para>Closes the application configuration.</para>
 /// </summary>
 /// <param name="node">
 /// <para>The node to execute the command upon.</para>
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     try
     {
         UIService.BeginUpdate();
         if (UIService.IsDirty(node.Hierarchy))
         {
             DialogResult result = UIService.ShowMessage(SR.SaveApplicationRequest, SR.SaveApplicationCaption, MessageBoxButtons.YesNo);
             if (DialogResult.Yes == result)
             {
                 if (!TryAndSaveApplication(node))
                 {
                     return;
                 }
             }
         }
         if (ConfigurationErrorLogService.ConfigurationErrors.Count > 0)
         {
             UIService.DisplayErrorLog(ConfigurationErrorLogService);
             DialogResult result = UIService.ShowMessage(SR.SaveApplicationErrorRequestMessage, SR.SaveApplicationCaption, MessageBoxButtons.YesNo);
             if (result == DialogResult.No)
             {
                 return;
             }
         }
         UIHierarchyService.RemoveHierarchy(node.Hierarchy.Id);
     }
     finally
     {
         UIService.EndUpdate();
     }
 }
예제 #4
0
 /// <summary>
 /// Executes the moving the node after it's sibling.
 /// </summary>
 /// <param name="node">
 /// The node to execute the command upon.
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     if (node.NextSibling != null)
     {
         node.Parent.MoveAfter(node, node.NextSibling);
     }
 }
        /// <summary>
        /// <para>Creates an instance of the child node class and adds it as a child of the parent node. The node will be a <see cref="SymmetricAlgorithmProviderNode"/>.</para>
        /// </summary>
        /// <param name="node">
        /// <para>The parent node to add the newly created <see cref="AddChildNodeCommand.ChildNode"/>.</para>
        /// </param>
        protected override void ExecuteCore(ConfigurationNode node)
        {
            TypeSelectorUI selector = new TypeSelectorUI(
                typeof(RijndaelManaged),
                typeof(SymmetricAlgorithm),
                TypeSelectorIncludes.None
                );

            DialogResult typeResult = selector.ShowDialog();
            if (typeResult == DialogResult.OK)
            {
                Type algorithmType = selector.SelectedType;
                CryptographicKeyWizard keyManager = new CryptographicKeyWizard(new SymmetricAlgorithmKeyCreator(algorithmType));
                DialogResult keyResult = keyManager.ShowDialog();

                if (keyResult == DialogResult.OK)
                {
                    INodeNameCreationService service = ServiceHelper.GetNameCreationService(ServiceProvider);
                    Debug.Assert(service != null, "Could not find the INodeNameCreationService");
                    base.ExecuteCore(node);
                    SymmetricAlgorithmProviderNode providerNode = (SymmetricAlgorithmProviderNode)ChildNode;
                    providerNode.AlgorithmType = selector.SelectedType;
                    providerNode.Name = service.GetUniqueName(selector.SelectedType.Name, providerNode, providerNode.Parent);
                    providerNode.Key = keyManager.KeySettings;
                }
            }
        }
예제 #6
0
 /// <summary>
 /// Executes the moving the node before it's sibling.
 /// </summary>
 /// <param name="node">
 /// The node to execute the command upon.
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     if (node.PreviousSibling != null)
     {
         node.Parent.MoveBefore(node, node.PreviousSibling);
     }
 }
예제 #7
0
 private void AddXmlIncludeTypes(ConfigurationNode node)
 {
     using (AddXmlIncludeTypesCommand includeTypesCommand = new AddXmlIncludeTypesCommand(ServiceProvider, false, childNode.GetType()))
     {
         includeTypesCommand.Execute(node);
     }
 }
        /// <summary>
        /// Closes the application configuration.
        /// </summary>
        /// <param name="node">
        /// The node to execute the command upon.
        /// </param>
        protected override void ExecuteCore(ConfigurationNode node)
        {
            try
            {
                UIService.BeginUpdate();

                if (UIService.IsDirty(node.Hierarchy))
                {
                    DialogResult result = UIService.ShowMessage(Resources.SaveApplicationRequest, Resources.SaveApplicationCaption, MessageBoxButtons.YesNo);
                    if (DialogResult.Yes == result)
                    {
                        if (!TryAndSaveApplication(node))
                        {
                            return;
                        }
                    }
                }
                if (ErrorLogService.ConfigurationErrorCount > 0)
                {
                    UIService.DisplayErrorLog(ErrorLogService);
                    DialogResult result = UIService.ShowMessage(Resources.SaveApplicationErrorRequestMessage, Resources.SaveApplicationCaption, MessageBoxButtons.YesNo);
                    if (result == DialogResult.No) return;
                }
                ConfigurationUIHierarchyService.RemoveHierarchy(node.Hierarchy.Id);
            }
            finally
            {
                UIService.EndUpdate();
            }
        }
예제 #9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="node"></param>
        protected override void ExecuteCore(ConfigurationNode node)
        {
            base.ExecuteCore(node);

            RuleNode ruleNode = ChildNode as RuleNode;
            if (ruleNode == null) return;
        }
예제 #10
0
 /// <summary>
 /// Creates the commands and adds them to the <see cref="IStorageService"/>.
 /// </summary>
 /// <param name="node">The node to execute the command upon.</param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     // clear out the service first since we are going to refill it
     IStorageService storageService = ServiceHelper.GetCurrentStorageService(ServiceProvider);
     storageService.Clear();
     CreateCommands(node);
 }
예제 #11
0
 protected override void ExecuteCore(ConfigurationNode node)
 {
     TypeSelectorUI selector = new TypeSelectorUI(
         typeof(Exception),
         typeof(Exception),
         TypeSelectorIncludeFlags.BaseType |
             TypeSelectorIncludeFlags.AbstractTypes);
     DialogResult result = selector.ShowDialog();
     if (result == DialogResult.OK)
     {
         base.ExecuteCore(node);
         ExceptionTypeNode typeNode = (ExceptionTypeNode) ChildNode;
         typeNode.TypeName = selector.SelectedType.AssemblyQualifiedName;
         typeNode.PostHandlingAction = PostHandlingAction.NotifyRethrow;
         try
         {
             typeNode.Name = selector.SelectedType.Name;
         }
         catch (InvalidOperationException)
         {
             typeNode.Remove();
             UIService.ShowError(SR.DuplicateExceptionTypeErrorMessage(selector.SelectedType.Name));
         }
     }
 }
예제 #12
0
 private void CreateCommands(ConfigurationNode node)
 {
     Type t = node.GetType();
     PropertyInfo[] properties = t.GetProperties(BindingFlags.Public | BindingFlags.Instance);
     CreateCommandsOnNode(node, properties);
     CreateCommandsOnChildNodeProperties(node);
 }
 /// <summary>
 /// Executes the moving the node before it's sibling.
 /// </summary>
 /// <param name="node">
 /// The node to execute the command upon.
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     if (node.PreviousSibling != null)
     {
         node.Parent.MoveBefore(node, node.PreviousSibling);
     }
 }
예제 #14
0
        /// <summary>
        /// Edits the value of the specified object using the editor style indicated by <seealso cref="UITypeEditor.GetEditStyle(ITypeDescriptorContext)"/>.
        /// </summary>
        /// <param name="context">An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information. </param>
        /// <param name="provider">An <see cref="IServiceProvider"/> that this editor can use to obtain services.</param>
        /// <param name="value">The object to edit.</param>
        /// <returns>The new value of the object.</returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (null == context)
            {
                return(null);
            }
            if (null == provider)
            {
                return(null);
            }

            IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (service != null)
            {
                ReferenceTypeAttribute       refTypeAttribute = GetReferenceType(context);
                ConfigurationNode            currentNode      = (ConfigurationNode)context.Instance;
                ConfigurationApplicationNode appNode          = GetApplicationNode(currentNode);
                ConfigurationNode            contextNode      = (refTypeAttribute.LocalOnly) ? currentNode : appNode;
                ReferenceEditorUI            control          = new ReferenceEditorUI(contextNode, refTypeAttribute.ReferenceType, (ConfigurationNode)value, service, IsRequired(context));
                service.DropDownControl(control);
                if (control.SelectedNode != null)
                {
                    Type propertyType     = context.PropertyDescriptor.PropertyType;
                    Type selectedNodeType = control.SelectedNode.GetType();
                    if (propertyType == selectedNodeType || selectedNodeType.IsSubclassOf(propertyType))
                    {
                        return(control.SelectedNode);
                    }
                }
            }

            return(null);
        }
예제 #15
0
 private void CreateCommandsOnChildNodeProperties(ConfigurationNode node)
 {
     foreach (ConfigurationNode childNode in node.Nodes)
     {
         CreateCommands(childNode);
     }
 }
 /// <summary>
 /// Executes the moving the node after it's sibling.
 /// </summary>
 /// <param name="node">
 /// The node to execute the command upon.
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     if (node.NextSibling != null)
     {
         node.Parent.MoveAfter(node, node.NextSibling);
     }
 }
예제 #17
0
        protected override void ExecuteCore(ConfigurationNode node)
        {
            ConfigurationSectionCollectionNode configurationSectionCollectionNode = node.Hierarchy.FindNodeByType(typeof(ConfigurationSectionCollectionNode)) as ConfigurationSectionCollectionNode;
            if (configurationSectionCollectionNode == null) return;

            IXmlIncludeTypeService service = GetService(typeof(IXmlIncludeTypeService)) as IXmlIncludeTypeService;
            Type[] types = null;
            XmlSerializerTransformerNode transformerNode = null;
            foreach (ConfigurationNode configurationNode in configurationSectionCollectionNode.Nodes)
            {
                transformerNode = node.Hierarchy.FindNodeByType(configurationNode, typeof(XmlSerializerTransformerNode)) as XmlSerializerTransformerNode;
                if (transformerNode == null) continue;
                types = service.GetXmlIncludeTypes(configurationNode.Name);
                if (types == null) continue;
                foreach (Type t in types)
                {
                    INodeCreationService nodeCreationService = (INodeCreationService)GetService(typeof(INodeCreationService));
                    if (!nodeCreationService.DoesNodeTypeMatchDataType(nodeType, t)) continue;
                    if (node.Hierarchy.FindNodeByName(transformerNode, t.Name) == null)
                    {
                        transformerNode.Nodes.Add(new XmlIncludeTypeNode(new XmlIncludeTypeData(t.Name, t.AssemblyQualifiedName)));
                    }
                }
            }
        }
예제 #18
0
        /// <summary>
        /// <para>Opens the configuration settings and registers them with the application.</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>
        public void Open(IServiceProvider serviceProvider)
        {
            ConfigurationContext configurationContext       = ServiceHelper.GetCurrentConfigurationContext(serviceProvider);
            ConfigurationSectionCollectionNode sectionsNode = null;
            ConfigurationNode configurationNode             = ServiceHelper.GetCurrentRootNode(serviceProvider);

            RemoveCurrentConfigurationSectionCollectionNode(serviceProvider);
            try
            {
                string appName = SR.DefaultApplicationName;
                ConfigurationSettings configurationSettings = configurationContext.GetMetaConfiguration();
                if (null != configurationSettings)
                {
                    appName = configurationSettings.ApplicationName;
                    if (configurationSettings.ConfigurationSections.Count > 0)
                    {
                        sectionsNode = new ConfigurationSectionCollectionNode(configurationSettings);
                        configurationNode.Nodes.Add(sectionsNode);
                    }
                }
                if (configurationNode is ApplicationConfigurationNode)
                {
                    ((ApplicationConfigurationNode)configurationNode).Name = appName;
                }
            }
            catch (ConfigurationException e)
            {
                ServiceHelper.LogError(serviceProvider, sectionsNode, e);
            }
        }
 /// <summary>
 /// Saves the application configuration.
 /// </summary>
 /// <param name="node">
 /// The node to execute the command upon.
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {            
     if (!DoValidationCommand())
     {
         return;
     }
     DoApplicationSave();
 }
예제 #20
0
		internal void UpdateHierarchy(ConfigurationNode configurationNode)
		{
			if (hierarchy != null)
			{
				hierarchy.AddNode(configurationNode);
				UpdateHierarchyRecursive(hierarchy, configurationNode);
			}
		}
예제 #21
0
 /// <summary>
 /// <para>Initializes a new instance of the <see cref="ConfigurationNodeChangedEventArgs"/> class with an action, the node it was performed upon, and the parent node.</para>
 /// </summary>
 /// <param name="action">
 /// <para>One of the <see cref="ConfigurationNodeChangedAction"/> values.</para>
 /// </param>
 /// <param name="node">
 /// <para>The <see cref="ConfigurationNode"/> that the action occured upon.</para>
 /// </param>
 /// <param name="parent"><para>The parent node of the <paramref name="node"/>.</para></param>
 public ConfigurationNodeChangedEventArgs(ConfigurationNodeChangedAction action,
                                          ConfigurationNode node,
                                          ConfigurationNode parent)
 {
     this.action = action;
     this.node   = node;
     this.parent = parent;
 }
        /// <summary>
        /// Adds the <see cref="LoggingSettingsNode"/> and adds the default nodes.
        /// </summary>
        /// <param name="node">The <see cref="LoggingSettingsNode"/> added.</param>
        protected override void ExecuteCore(ConfigurationNode node)
        {
            base.ExecuteCore(node);
            ApplicationBlockSettingsNode blockSettingsNode = ChildNode as ApplicationBlockSettingsNode;
            if (blockSettingsNode == null) return;

            // TODO: Initialize your initial configuration settings for the MyNewApplicationBlock7 Design Time.
        }
		/// <summary>
		/// After the <see cref="SecuritySettingsNode"/> is added, adds the default nodes.
		/// </summary>
		/// <param name="node">The <see cref="SecuritySettingsNode"/>.S</param>
        protected override void ExecuteCore(ConfigurationNode node)
        {
            base.ExecuteCore(node);
            SecuritySettingsNode securitySettingsNode = (SecuritySettingsNode)ChildNode;

            securitySettingsNode.AddNode(new AuthorizationProviderCollectionNode());
            securitySettingsNode.AddNode(new SecurityCacheProviderCollectionNode());
        }
 /// <summary>
 /// <para>Adds a previously created node to the end of the collection and adds any default.</para>
 /// </summary>
 /// <param name="node"><para>The <see cref="ConfigurationNode"/> to add to the collection.</para></param>
 /// <returns><para>The zero-based index value of the <see cref="ConfigurationNode"/> added to the tree node collection.</para></returns>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="node"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
 /// </exception>
 public int AddWithDefaultChildren(ConfigurationNode node)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     return(owner.AddNodeWithDefaultChildren(node));
 }
예제 #25
0
        private void Validate(ConfigurationNode node, ValidationErrorCollection errors)
        {
            Type t = node.GetType();

            PropertyInfo[] properties = t.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            ValidateProperties(node, properties, errors);
            ValidateChildNodeProperties(node, errors);
        }
        private void CreateCommands(ConfigurationNode node)
        {
            Type t = node.GetType();

            PropertyInfo[] properties = t.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            CreateCommandsOnNode(node, properties);
            CreateCommandsOnChildNodeProperties(node);
        }
 /// <summary>
 /// Saves the application configuration.
 /// </summary>
 /// <param name="node">
 /// The node to execute the command upon.
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     if (!DoValidationCommand())
     {
         return;
     }
     DoApplicationSave();
 }
 /// <summary>
 /// <para>Initializes a new instance of the <see cref="ConfigurationNodeChangedEventArgs"/> class with an action, the node it was performed upon, and the parent node.</para>
 /// </summary>
 /// <param name="action">
 /// <para>One of the <see cref="ConfigurationNodeChangedAction"/> values.</para>
 /// </param>
 /// <param name="node">
 /// <para>The <see cref="ConfigurationNode"/> that the action occured upon.</para>
 /// </param>
 /// <param name="parent"><para>The parent node of the <paramref name="node"/>.</para></param>
 public ConfigurationNodeChangedEventArgs(ConfigurationNodeChangedAction action,
                                          ConfigurationNode node,
                                          ConfigurationNode parent)
 {
     this.action = action;
     this.node = node;
     this.parent = parent;
 }
        /// <summary>
        /// Creates the commands and adds them to the <see cref="IStorageService"/>.
        /// </summary>
        /// <param name="node">The node to execute the command upon.</param>
        protected override void ExecuteCore(ConfigurationNode node)
        {
            // clear out the service first since we are going to refill it
            IStorageService storageService = ServiceHelper.GetCurrentStorageService(ServiceProvider);

            storageService.Clear();
            CreateCommands(node);
        }
 /// <summary>
 /// <para>Adds a previously created node to the end of the collection.</para>
 /// </summary>
 /// <param name="node"><para>The <see cref="ConfigurationNode"/> to add to the collection.</para></param>
 /// <returns><para>The zero-based index value of the <see cref="ConfigurationNode"/> added to the tree node collection.</para></returns>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="node"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
 /// </exception>
 /// <see cref="IList.Add"/>
 public int Add(ConfigurationNode node)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     return(owner.AddNode(node));
 }
예제 #31
0
        public void RemoveNode(ConfigurationNode configurationNode)
        {
            if (null == configurationNode)
            {
                throw new ArgumentNullException("configurationNode");
            }

            configurationNode.RemoveThisNode(ParentNodeNotification.Notify);
        }
예제 #32
0
 /// <summary>
 /// Shows an dialog that allows the user to export an cryptographic key.
 /// </summary>
 /// <param name="node">
 /// The <see cref="ConfigurationNode"/> of which an cryptographic key should be exported.
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     ICryptographicKeyConfigurationNode cryptographicNode = node as ICryptographicKeyConfigurationNode;
     if (cryptographicNode != null)
     {
         ExportKeyUI exportKeyDialog = new ExportKeyUI(cryptographicNode.KeySettings.ProtectedKey);
         exportKeyDialog.ShowDialog();
     }
 }
        /// <summary>
        /// Load an error when creating a node.
        /// </summary>
        /// <param name="node">The node where the error occurred.</param>
        /// <param name="configType">The type trying to be created.</param>
        protected void LogNodeMapError(ConfigurationNode node, MemberInfo configType)
        {
            if (null == configType)
            {
                throw new ArgumentNullException("configType");
            }

            LogError(node, string.Format(CultureInfo.CurrentUICulture, Resources.ExceptionNodeMapNotRegistered, configType.Name));
        }
예제 #34
0
 public ReferenceEditorUI(ConfigurationNode rootNode, Type referenceType, ConfigurationNode currentReference, IWindowsFormsEditorService service, bool isRequired) : this()
 {
     this.rootNode      = rootNode;
     this.referenceType = referenceType;
     this.currentNode   = currentReference;
     this.service       = service;
     this.isRequired    = isRequired;
     DisplayList();
 }
예제 #35
0
        /// <summary>
        /// <para>Creates an instance of the child node class and adds it as a child of the parent node. The node will be a <see cref="RuleSetNode"/>.</para>
        /// </summary>
        /// <param name="node">
        /// <para>The parent node to add the newly created <see cref="RuleSetNode"/>.</para>
        /// </param>
        protected override void ExecuteCore(ConfigurationNode node)
        {
            base.ExecuteCore(node);

            RuleSetNode ruleNode = ChildNode as RuleSetNode;
            if (ruleNode == null) return;

            ruleNode.AddNode(new SelfNode());
        }
예제 #36
0
		/// <summary>
		/// Compares the specified node to the current node based on the value of the <seealso cref="Name"/> property.
		/// </summary>
		/// <param name="obj">An object to compare.></param>
		/// <returns>
		/// A signed integer that indicates the relative order of this node and the node being compared.
		/// </returns>
		int IComparable.CompareTo(object obj)
		{
			ConfigurationNode compareNode = obj as ConfigurationNode;
			if (compareNode == null)
			{
				return -1;
			}
			return id.CompareTo(compareNode.Id);
		}
        /// <summary>
        /// Gets the command state of the node.
        /// </summary>
        /// <param name="node">The node used to get the command state.</param>
        /// <returns>One of the <see cref="CommandState"/> values.</returns>
        /// <remarks>
        /// If the node is the last node in the list, the command state will be <see cref="CommandState.Disabled"/>.
        /// </remarks>
        public override CommandState GetCommandState(ConfigurationNode node)
        {
            if (null == node)
            {
                throw new ArgumentNullException("node");
            }

            return(node.NextSibling != null ? CommandState.Enabled : CommandState.Disabled);
        }
예제 #38
0
 /// <summary>
 /// <para>Finds nodes by their <see cref="Type"/>.</para>
 /// </summary>
 /// <param name="parent">
 /// <para>The parent to start the search.</para>
 /// </param>
 /// <param name="type">
 /// <para>The <see cref="Type"/> of the node.</para>
 /// </param>
 /// <returns>
 /// <para>The node if found or <see langword="null"/> if not found.</para>
 /// </returns>
 /// <remarks>
 /// <para>If this is more than one type in the hierachy, this function will only find the first one found.</para>
 /// </remarks>
 public ConfigurationNode FindNodeByType(ConfigurationNode parent, Type type)
 {
     ConfigurationNode[] nodes = FindNodesByType(parent, type);
     if (nodes.Length > 0)
     {
         return(nodes[0]);
     }
     return(null);
 }
예제 #39
0
        /// <summary>
        /// <para>Initialize a new instance of the <see cref="MoveNodeAfterCommand"/> class with an <see cref="IServiceProvider"/>, the node to move, and the sibling node to move it after.</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="clearErrorLog">
        /// <para>Determines if all the messages in the <see cref="IConfigurationErrorLogService"/> should be cleared when the command has executed.</para>
        /// </param>
        /// <param name="nodeToMove">
        /// <para>The node to move.</para>
        /// </param>
        /// <param name="siblingNode">
        /// <para>The sibling node to move <paramref name="nodeToMove"/> after.</para>
        /// </param>
        public MoveNodeAfterCommand(IServiceProvider serviceProvider, bool clearErrorLog, ConfigurationNode nodeToMove, ConfigurationNode siblingNode)
            : base(serviceProvider, clearErrorLog)
        {
            if (nodeToMove == null) throw new ArgumentNullException("nodeToMove");
            if (siblingNode == null) throw new ArgumentNullException("siblingNode");

            this.nodeToMove = nodeToMove;
            this.siblingNode = siblingNode;
        }
예제 #40
0
		/// <summary>
		/// Log an error to the <see cref="IErrorLogService"/>.
		/// </summary>
		/// <param name="serviceProvider">
		/// The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.
		/// </param>
		/// <param name="node">The configuration node associated with the error.</param>
		/// <param name="e">The <see cref="Exception"/> to log.</param>
		public static void LogError(IServiceProvider serviceProvider, ConfigurationNode node, Exception e)
		{
			Exception exception = e;
			while (exception != null)
			{
				LogError(serviceProvider, new ConfigurationError(node, exception.Message));
				exception = exception.InnerException;
			}
		}
예제 #41
0
 public ConfigurationMenuItem(ConfigurationNode node, ConfigurationUICommand command)
 {
     Debug.Assert(node != null);
     this.command = command;
     Shortcut = command.Shortcut;
     Text = command.Text;
     this.node = node;
     this.Enabled = (command.GetCommandState(node) == CommandState.Enabled);
 }
예제 #42
0
        /// <summary>
        /// Finds nodes by their <see cref="Type"/>.
        /// </summary>
        /// <param name="parent">
        /// The parent to start the search.
        /// </param>
        /// <param name="type">
        /// The <see cref="Type"/> of the node.
        /// </param>
        /// <returns>
        /// The node if found or <see langword="null"/> if not found.
        /// </returns>
        /// <remarks>
        /// If this is more than one type in the hierachy, this function will only find the first one found.
        /// </remarks>
        public ConfigurationNode FindNodeByType(ConfigurationNode parent, Type type)
        {
            IList <ConfigurationNode> nodes = FindNodesByType(parent, type);

            if (nodes.Count > 0)
            {
                return(nodes[0]);
            }
            return(null);
        }
예제 #43
0
 public UIHierarchy(ConfigurationNode node, IServiceProvider serviceProvider, ConfigurationContext configurationContext) : this(serviceProvider, configurationContext)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     rootNode     = node;
     selectedNode = node;
     AddNode(node);
 }
        public ValidationErrorListViewItem(ValidationError error) : base()
        {
            Text = error.InvalidItem.ToString();
            this.error = error;
			node = error.InvalidItem as ConfigurationNode;
            StateImageIndex = 0;
            SubItems.Add(error.PropertyName);
            SubItems.Add(error.Message);
            SubItems.Add(node.Path);
        }
예제 #45
0
        /// <summary>
        /// <para>Finds nodes by their <seealso cref="ConfigurationNode.Name"/>.</para>
        /// </summary>
        /// <param name="parent">
        /// <para>The parent to start the search.</para>
        /// </param>
        /// <param name="name">
        /// <para>The name of the node.</para>
        /// </param>
        /// <returns>
        /// <para>The node if found or <see langword="null"/> if not found.</para>
        /// </returns>
        public ConfigurationNode FindNodeByName(ConfigurationNode parent, string name)
        {
            if (!nodesByName.Contains(parent.Id))
            {
                return(null);
            }
            Hashtable childs = (Hashtable)nodesByName[parent.Id];

            return((ConfigurationNode)childs[name]);
        }
예제 #46
0
        private static void AddBaseTypes(ConfigurationNode node, ArrayList tableToAddTypes)
        {
            Type searchType = node.GetType().BaseType;

            while (searchType != null && searchType != typeof(ConfigurationNode))
            {
                tableToAddTypes.Add(new NodeTypeEntry(node, searchType.FullName));
                searchType = searchType.BaseType;
            }
        }
예제 #47
0
        /// <summary>
        /// Log an error to the <see cref="IErrorLogService"/>.
        /// </summary>
        /// <param name="serviceProvider">
        /// The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.
        /// </param>
        /// <param name="node">The configuration node associated with the error.</param>
        /// <param name="e">The <see cref="Exception"/> to log.</param>
        public static void LogError(IServiceProvider serviceProvider, ConfigurationNode node, Exception e)
        {
            Exception exception = e;

            while (exception != null)
            {
                LogError(serviceProvider, new ConfigurationError(node, exception.Message));
                exception = exception.InnerException;
            }
        }
예제 #48
0
        /// <summary>
        /// <para>Compares the specified node to the current node based on the value of the <seealso cref="Name"/> property.</para>
        /// </summary>
        /// <param name="node"><para>An object to compare.</para></param>
        /// <returns>
        /// <para>A signed integer that indicates the relative order of this node and the node being compared.</para>
        /// </returns>
        int IComparable.CompareTo(object node)
        {
            ConfigurationNode compareNode = node as ConfigurationNode;

            if (compareNode == null)
            {
                return(-1);
            }
            return(Id.CompareTo(compareNode.Id));
        }
예제 #49
0
 public ReferenceEditorUI(ConfigurationNode rootNode, Type referenceType, ConfigurationNode currentReference, IWindowsFormsEditorService service, bool isRequired)
     : this()
 {
     this.rootNode = rootNode;
     this.referenceType = referenceType;
     this.currentNode = currentReference;
     this.service = service;
     this.isRequired = isRequired;
     DisplayList();
 }
        /// <summary>
        /// Creates an instance of the child node class and adds it as a child of the parent node.
        /// </summary>
        /// <param name="node">
        /// The parent node to add the newly created <see cref="AddChildNodeCommand.ChildNode"/>.
        /// </param>
        protected override void ExecuteCore(ConfigurationNode node)
        {
            base.ExecuteCore(node);

            EnvironmentNode envNode = ChildNode as EnvironmentNode;
            if (envNode != null)
            {
                envNode.EnvironmentDeltaFile = string.Concat(envNode.Name, Resources.DefaultEnvironmentDeltaFileExtension);
            }

        }
 /// <summary>
 /// <para>Creates a <see cref="ConfigurationSectionNode"/> for the parent node.</para>
 /// </summary>
 /// <param name="node">
 /// <para>The parent node to add the newly created <see cref="ConfigurationSectionNode"/>.</para>
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     ConfigurationSectionCollectionNode sectionsNode = SelectConfigurationSectionsNode();
     ConfigurationSectionNode sectionNode = UIHierarchyService.SelectedHierarchy.FindNodeByName(sectionsNode, sectionName) as ConfigurationSectionNode;
     newSectionNode = sectionNode;
     if (sectionNode == null)
     {
         newSectionNode = ConfigurationSectionNode.CreateReadOnlyDefault(sectionName, sectionsNode);
     }
     base.ExecuteCore(node);
 }
예제 #52
0
 public UIHierarchy(ConfigurationNode node, IServiceProvider serviceProvider, ConfigurationContext configurationContext)
     : this(serviceProvider, configurationContext)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     rootNode = node;
     selectedNode = node;
     AddNode(node);
 }
예제 #53
0
        private static void RemoveBaseTypes(ConfigurationNode node, NodeTypeEntryArrayList tableToAddTypes)
        {
            Type searchType = node.GetType().BaseType;

            while (searchType != null)
            {
                NodeTypeEntry entry = new NodeTypeEntry(node, searchType.FullName);
                tableToAddTypes.Remove(entry);
                searchType = searchType.BaseType;
            }
        }
        private bool CreateMetaDataConfiguration(ConfigurationNode node)
        {
            MetaDataStorageCreationCommand cmd = new MetaDataStorageCreationCommand(node.Hierarchy.StorageTable.MetaConfigurationFile, ServiceProvider);

            cmd.Execute();
            if (cmd.CreationCancled)
            {
                return(false);
            }
            return(true);
        }
 /// <summary>
 /// <para>Determines the index of a specific node in the collection.</para>
 /// </summary>
 /// <param name="node"><para>Determines the index of a specific node in the collection.</para></param>
 /// <returns><para>The index of the node if found in the list; otherwise, -1.</para></returns>
 /// <seealso cref="IList.IndexOf"/>
 public int IndexOf(ConfigurationNode node)
 {
     for (int index = 0; index < Count; ++index)
     {
         if (this[index].CompareTo(node) == 0)
         {
             return(index);
         }
     }
     return(-1);
 }
 /// <summary>
 /// <para>Saves the application configuration.</para>
 /// </summary>
 /// <param name="node">
 /// <para>The node to execute the command upon.</para>
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     Debug.Assert(node.GetType().Equals(typeof(ApplicationConfigurationNode)));
     if (!DoValidationCommand(node))
     {
         return;
     }
     if (!DoApplicationSave(node))
     {
         return;
     }
 }
        /// <summary>
        /// Intercepts Command.Execute() and launches a <c>KeyManager</c> prompting the user to manage a key.
        /// </summary>
        protected override void ExecuteCore(ConfigurationNode node)
        {
            ExpressionEditorFormUI formUI = new ExpressionEditorFormUI();
            formUI.RuleName = SR.AuthorizationRuleNodeName;
            DialogResult result = formUI.ShowDialog();

            if (result == DialogResult.OK)
            {
                base.ExecuteCore(node);
                AuthorizationRuleNode ruleNode = (AuthorizationRuleNode)ChildNode;
                ruleNode.Expression = formUI.Expression;
            }
        }
        protected override void ExecuteCore(ConfigurationNode node)
        {
            DpapiSettingsEditorUI dpapi = new DpapiSettingsEditorUI();
            DialogResult result = dpapi.ShowDialog();

            if (result == DialogResult.OK)
            {
                base.ExecuteCore(node);
                DpapiSymmetricCryptoProviderNode cryptoNode = (DpapiSymmetricCryptoProviderNode)ChildNode;
                DpapiSettings settings = new DpapiSettings(dpapi.DpapiSettingsData);
                cryptoNode.DataProtectionMode = settings;
            }
        }
예제 #59
0
 /// <devdoc>
 /// Get the reference to a ConfigurationNode wiring up the ConfigurationNode.Removed and ConfigurationNode.Renamed events.
 /// </devdoc>
 public ConfigurationNode CreateReference(ConfigurationNode oldReference, ConfigurationNode newReference, ConfigurationNodeChangedEventHandler referenceRemovedHandler, ConfigurationNodeChangedEventHandler referenceRenamedHandler)
 {
     ConfigurationNode node = CreateReference(oldReference, newReference, referenceRemovedHandler);
     if (node != null && node != oldReference)
     {
         if (oldReference != null)
         {
             oldReference.Renamed -= referenceRenamedHandler;
         }
         node.Renamed += referenceRenamedHandler;
     }
     return node;
 }
예제 #60
0
 /// <summary>
 /// Removes the node from the <see cref="IConfigurationUIHierarchy"/>.
 /// </summary>
 /// <param name="node">
 /// The node to execute the command upon.
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     try
     {
         UIService.BeginUpdate();
         UIService.SetUIDirty(node.Hierarchy);
         node.Remove();
     }
     finally
     {
         UIService.EndUpdate();
     }
 }