public static void Save(ConnectionProperties connectionProperties, ConfigurationNode configurationNode)
        {
            var attributes = configurationNode.Attributes;

            attributes.SetAttributeValue("ConnectionName", connectionProperties.ConnectionName);
            attributes.SetAttributeValue("ProviderName", connectionProperties.ProviderName);
            attributes.SetAttributeValue(ConnectionStringKeyword.DataSource, connectionProperties.DataSource);
            attributes.SetAttributeValue(ConnectionStringKeyword.InitialCatalog, connectionProperties.InitialCatalog);
            attributes.SetAttributeValue(ConnectionStringKeyword.IntegratedSecurity, connectionProperties.IntegratedSecurity);
            attributes.SetAttributeValue(ConnectionStringKeyword.UserId, connectionProperties.UserId);

            if (connectionProperties.Password != null)
            {
                attributes.SetAttributeValue(ConnectionStringKeyword.Password, ProtectPassword(connectionProperties.Password.Value));
            }
            else
            {
                attributes.Remove(ConnectionStringKeyword.Password);
            }

            var connectionStringBuilder = new DbConnectionStringBuilder();

            connectionStringBuilder.ConnectionString = connectionProperties.ConnectionString;
            connectionStringBuilder.Remove(ConnectionStringKeyword.Password);
            attributes.SetAttributeValue("ConnectionString", connectionStringBuilder.ConnectionString);
        }
        public void TestInitialize()
        {
            node = new ConfigurationApplicationNode(ConfigurationApplicationFile.FromCurrentAppDomain());
            message = "Test";
			propertyInfo = node.GetType().GetProperty("ConfigurationFile");
            error = new ValidationError(node, propertyInfo.Name, message);
        }
Beispiel #3
0
 public override void ProcessFile(StringBuilder fileContents, string input, ConfigurationNode Node)
 {
     if (Node.Processor == "UserInput")
     {
         fileContents.Replace(Node.Name, input);
     }
 }
Beispiel #4
0
    private void Load(out ConfigurationNode rootNode, out StringCollection fileNames)
    {
        var reader = new ConfigurationReader();

        fileNames = new StringCollection();
        rootNode  = reader.Read(ConfigFileName, SectionName, fileNames);
    }
Beispiel #5
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            Debug.Assert(provider != null, "No service provider; we cannot edit the value");
            if (provider != null)
            {
                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                Debug.Assert(edSvc != null, "No editor service; we cannot edit the value");
                if (edSvc != null)
                {
                    IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                    string            expression       = (string)value;
                    ConfigurationNode node             = (ConfigurationNode)context.Instance;

                    formUI.Expression = expression;
                    formUI.RuleName   = node.Name;

                    DialogResult result = service.ShowDialog(formUI);
                    if (result == DialogResult.OK)
                    {
                        expression = formUI.Expression;
                        if (node.Name != formUI.RuleName)
                        {
                            INodeNameCreationService nameCreationService = node.Site.GetService(typeof(INodeNameCreationService)) as INodeNameCreationService;
                            node.Name = nameCreationService.GetUniqueDisplayName(node, formUI.RuleName);
                        }
                    }
                    return(expression);
                }
            }
            return(value);
        }
Beispiel #6
0
        private void CreateStorageNode(CacheManagerNode cacheManagerNode, string cacheStorageName)
        {
            if (string.IsNullOrEmpty(cacheStorageName))
            {
                return;
            }

            CacheStorageData cacheStorageData = cacheManagerSettings.BackingStores.Get(cacheStorageName);

            if (null == cacheStorageData)
            {
                LogError(cacheManagerNode, string.Format(CultureInfo.CurrentUICulture, Resources.ExceptionNoStorageProviderDefined, cacheStorageName));
                return;
            }
            if (cacheStorageData.TypeName != null &&
                cacheStorageData.TypeName.StartsWith(typeof(NullBackingStore).FullName))
            {
                return;                                                                          // special case
            }
            ConfigurationNode storageNode = NodeCreationService.CreateNodeByDataType(cacheStorageData.GetType(), new object[] { cacheStorageData });

            if (null == storageNode)
            {
                LogNodeMapError(cacheManagerNode, cacheStorageData.GetType());
                return;
            }
            cacheManagerNode.AddNode(storageNode);
            CreateEncryptionNode(storageNode, cacheStorageData.StorageEncryption);
        }
Beispiel #7
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));
                }
            }
        }
Beispiel #8
0
        protected override ConfigurationSectionInfo GetConfigurationSectionInfo(
            IServiceProvider serviceProvider)
        {
            ConfigurationNode rootNode = ServiceHelper.GetCurrentRootNode(serviceProvider);

            WebServiceSettingsNode node = null;

            if (rootNode != null)
            {
                node = (WebServiceSettingsNode)rootNode.Hierarchy.FindNodeByType(
                    rootNode,
                    typeof(WebServiceSettingsNode));
            }

            WebServiceSettings webServiceSection = null;

            if (node == null)
            {
                webServiceSection = null;
            }
            else
            {
                WebServiceSettingsBuilder builder = new WebServiceSettingsBuilder(serviceProvider, node);
                webServiceSection = builder.Build();
            }

            return(new ConfigurationSectionInfo(node, webServiceSection, WebServiceSettings.SectionName));
        }
Beispiel #9
0
        protected virtual IUIHierarchy CreateHierarchyAndAddToHierarchyService(ConfigurationNode node, ConfigurationContext configurationContext)
        {
            UIHierarchy hierarchy = new UIHierarchy(node, host, configurationContext);

            hierarchyService.AddHierarchy(hierarchy);
            return(hierarchy);
        }
Beispiel #10
0
        private void AddValidatorNodes(ConfigurationNode parentNode, ValidatorDataCollection validatorCollection)
        {
            foreach (ValidatorData validator in validatorCollection)
            {
                ConfigurationNode validatorNode = NodeCreationService.CreateNodeByDataType(validator.GetType(), new object[] { validator });
                if (validatorNode == null)
                {
                    LogNodeMapError(parentNode, validator.GetType());
                    continue;
                }

                if (validator is OrCompositeValidatorData)
                {
                    ValidatorDataCollection childValidators = ((OrCompositeValidatorData)validator).Validators;

                    AddValidatorNodes(validatorNode, childValidators);
                }
                else if (validator is AndCompositeValidatorData)
                {
                    ValidatorDataCollection childValidators = ((AndCompositeValidatorData)validator).Validators;

                    AddValidatorNodes(validatorNode, childValidators);
                }

                parentNode.AddNode(validatorNode);
            }
        }
Beispiel #11
0
 public void TestInitialize()
 {
     node         = new ConfigurationApplicationNode(ConfigurationApplicationFile.FromCurrentAppDomain());
     message      = "Test";
     propertyInfo = node.GetType().GetProperty("ConfigurationFile");
     error        = new ValidationError(node, propertyInfo.Name, message);
 }
Beispiel #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="node"></param>
        protected override void ExecuteCore(ConfigurationNode node)
        {
            ManageableConfigurationSourceElementNode sourceNode = node as ManageableConfigurationSourceElementNode;

            if (sourceNode != null)
            {
                // check current configuration == selected configuration?

                // check for dirty and ask for saving
                if (UIService.IsDirty(node.Hierarchy))
                {
                    DialogResult result
                        = UIService.ShowMessage(Resources.SaveApplicationBeforeExportingAdmRequest,
                                                Resources.SaveApplicationCaption,
                                                MessageBoxButtons.YesNo);
                    if (DialogResult.Yes == result)
                    {
                        if (!TryAndSaveApplication(node))
                        {
                            return;
                        }
                    }
                }

                TryAndExportAdmTemplate(sourceNode);
            }
        }
        public override void FinishInit()
        {
            base.FinishInit();

            var arl = (AtomicReferenceLauncher)Control;

            arl.Initialize(m_cache, m_obj, m_flid, m_fieldName, m_persistenceProvider, Mediator,
                           DisplayNameProperty,
                           BestWsName);      // TODO: Get better default 'best ws'.
            arl.ConfigurationNode = ConfigurationNode;
            XmlNode deParams = ConfigurationNode.SelectSingleNode("deParams");

            if (XmlUtils.GetOptionalBooleanAttributeValue(
                    deParams, "changeRequiresRefresh", false))
            {
                arl.ChoicesMade += RefreshTree;
            }

            // We don't want to be visible until later, since otherwise we get a temporary
            // display in the wrong place with the wrong size that serves only to annoy the
            // user.  See LT-1518 "The drawing of the DataTree for Lexicon/Advanced Edit draws
            // some initial invalid controls."  Becoming visible when we set the width and
            // height seems to delay things enough to avoid this visual clutter.
            // Now done in Slice.ctor
            //arl.Visible = false;
            arl.ViewSizeChanged += OnViewSizeChanged;
            var view = (AtomicReferenceView)arl.MainControl;

            view.ViewSizeChanged += OnViewSizeChanged;
        }
        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;
                }
            }
        }
Beispiel #15
0
 /// <summary>
 /// Sets the formatter node reference.
 /// </summary>
 /// <param name="formatterNodeReference"></param>
 protected override void SetFormatterReference(ConfigurationNode formatterNodeReference)
 {
     if (formatterName == formatterNodeReference.Name)
     {
         Formatter = (FormatterNode)formatterNodeReference;
     }
 }
        protected override ConfigurationSectionInfo GetConfigurationSectionInfo(IServiceProvider serviceProvider)
        {
            ConfigurationNode            rootNode            = ServiceHelper.GetCurrentRootNode(serviceProvider);
            ConnectionStringsSectionNode node                = null;
            DatabaseSectionNode          databaseSectionNode = null;

            if (null != rootNode)
            {
                node = rootNode.Hierarchy.FindNodeByType(rootNode, typeof(ConnectionStringsSectionNode)) as ConnectionStringsSectionNode;
                databaseSectionNode = rootNode.Hierarchy.FindNodeByType(rootNode, typeof(DatabaseSectionNode)) as DatabaseSectionNode;
            }
            ConnectionStringsSection connectionStrings = null;

            if (node == null)
            {
                connectionStrings = null;
            }
            else
            {
                ConnectionStringsSectionBuilder builder = new ConnectionStringsSectionBuilder(serviceProvider, node);
                connectionStrings = builder.Build();
            }
            string protectionProviderName = GetProtectionProviderName(databaseSectionNode);

            return(new ConfigurationSectionInfo(node, connectionStrings, "connectionStrings", protectionProviderName));
        }
        public void LookingUpANodeByNameThatDoesNotExistReturnsNull()
        {
            rootNode.AddNode(new MyNode());
            ConfigurationNode node = rootNode.Nodes["NotThere"];

            Assert.IsNull(node);
        }
Beispiel #18
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="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;
                }
            }
        }
        public void CanCreateIsolatedStorageCacheStorageNodeByDataType()
        {
            ConfigurationNode node = ServiceHelper.GetNodeCreationService(ServiceProvider).CreateNodeByDataType(typeof(IsolatedStorageCacheStorageData), new object[] { new IsolatedStorageCacheStorageData() });

            Assert.IsNotNull(node);
            Assert.AreEqual(typeof(IsolatedStorageCacheStorageNode), node.GetType());
        }
Beispiel #20
0
        public void FindNodeByNameWhenParentNotInHierarchyReturnsNull()
        {
            TestNode          node      = new TestNode("Child");
            ConfigurationNode foundNode = Hierarchy.FindNodeByName(node, "Child3");

            Assert.IsNull(foundNode);
        }
        public void LoadProtectedPassword(ConfigurationNode node)
        {
            string password;
            var    contains = node.Attributes.TryGetAttributeValue("Password", out password);

            if (contains)
            {
                var succeeded = false;
                try
                {
                    password  = UnprotectPassword(password);
                    succeeded = true;
                }
                catch (Exception e)
                {
                    Log.Write(LogLevel.Error, e.ToString());
                }

                if (succeeded)
                {
                    var dbConnectionStringBuilder = new DbConnectionStringBuilder();
                    dbConnectionStringBuilder.ConnectionString = ConnectionString;
                    dbConnectionStringBuilder[ConnectionStringKeyword.Password] = password;
                    ConnectionString = dbConnectionStringBuilder.ConnectionString;
                }
            }
        }
Beispiel #22
0
        public void CanCreateCachingStoreProviderNodeFromData()
        {
            ConfigurationNode createdNode = ServiceHelper.GetNodeCreationService(ServiceProvider).CreateNodeByDataType(typeof(CachingStoreProviderData), new object[] { new CachingStoreProviderData() });

            Assert.IsNotNull(createdNode);
            Assert.AreEqual(typeof(CachingStoreProviderNode), createdNode.GetType());
        }
Beispiel #23
0
        private void LoadConnection(ConfigurationNode folder, DataRow row)
        {
            var connectionProperties = new ConnectionProperties();

            connectionProperties.Load(folder);
            row["ConnectionName"] = connectionProperties.ConnectionName;
            row["ProviderName"]   = connectionProperties.ProviderName;
            row[ConnectionStringKeyword.DataSource]         = connectionProperties.DataSource;
            row[ConnectionStringKeyword.InitialCatalog]     = connectionProperties.InitialCatalog;
            row[ConnectionStringKeyword.IntegratedSecurity] = connectionProperties.IntegratedSecurity;
            row[ConnectionStringKeyword.UserId]             = connectionProperties.UserId;

            //var provider = ProviderFactory.CreateProvider(connectionProperties.ProviderName);
            //var connectionStringBuilder = provider.CreateConnectionStringBuilder();
            //connectionStringBuilder.ConnectionString = connectionProperties.ConnectionString;

            //foreach (DataColumn dataColumn in this.dataTable.Columns.Cast<DataColumn>().Skip(2))
            //{
            //    object value;
            //    if (connectionStringBuilder.TryGetValue(dataColumn.ColumnName, out value))
            //    {
            //        row[dataColumn.ColumnName] = value;
            //    }
            //}
        }
Beispiel #24
0
        public void ExecutingAddLoggingSettingsAddsDefaults()
        {
            AddLoggingSettingsNodeCommand addLoggingSettingsCommand = new AddLoggingSettingsNodeCommand(ServiceProvider);

            addLoggingSettingsCommand.Execute(ApplicationNode);
            LoggingSettingsNode loggingSettingsNode = (LoggingSettingsNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(LoggingSettingsNode));
            FormattedEventLogTraceListenerNode defaultEventLogListenerNode      = (FormattedEventLogTraceListenerNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(FormattedEventLogTraceListenerNode));
            TextFormatterNode                 defaultFormatterNode              = (TextFormatterNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(TextFormatterNode));
            ErrorsTraceSourceNode             errorTraceSourceNode              = (ErrorsTraceSourceNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(ErrorsTraceSourceNode));
            CategoryTraceSourceCollectionNode categoryCollectionNode            = (CategoryTraceSourceCollectionNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(CategoryTraceSourceCollectionNode));
            TraceListenerReferenceNode        defaultErrorListenerReferenceNode = (TraceListenerReferenceNode)Hierarchy.FindNodeByType(errorTraceSourceNode, typeof(TraceListenerReferenceNode));

            Assert.AreEqual(1, categoryCollectionNode.Nodes.Count);
            ConfigurationNode          generalCategoryNode = categoryCollectionNode.Nodes[0];
            TraceListenerReferenceNode defaultGeneralCategoryListenerRefenceNode = (TraceListenerReferenceNode)Hierarchy.FindNodeByType(generalCategoryNode, typeof(TraceListenerReferenceNode));

            Assert.AreEqual("General", generalCategoryNode.Name);
            Assert.IsNotNull(defaultErrorListenerReferenceNode);
            Assert.IsNotNull(defaultGeneralCategoryListenerRefenceNode);
            Assert.IsNotNull(defaultFormatterNode);
            Assert.IsNotNull(defaultEventLogListenerNode);
            Assert.AreEqual(defaultFormatterNode, defaultEventLogListenerNode.Formatter);
            Assert.AreEqual(defaultEventLogListenerNode, defaultGeneralCategoryListenerRefenceNode.ReferencedTraceListener);
            Assert.AreEqual(defaultEventLogListenerNode, defaultErrorListenerReferenceNode.ReferencedTraceListener);
            Assert.AreEqual(loggingSettingsNode.DefaultCategory, generalCategoryNode);
        }
Beispiel #25
0
        /// <summary>
        /// Returns a boolen on whether the given <see cref="System.Object"/> can contain overridden properties in its designtime.
        /// </summary>
        /// <param name="extendee">An instance of <see cref="ConfigurationNode"/> that is contained within a <see cref="IConfigurationUIHierarchy"/>.</param>
        /// <returns><see langword="true"/> if the <paramref name="extendee"/> can be extended, otherwise <see langword="false"/>.</returns>
        public bool CanExtend(object extendee)
        {
            ConfigurationNode configurationNodeToExtend = extendee as ConfigurationNode;

            if (configurationNodeToExtend == null)
            {
                return(false);
            }
            if (configurationNodeToExtend.Hierarchy == null)
            {
                return(false);
            }

            if (typeof(EnvironmentNode).IsAssignableFrom(configurationNodeToExtend.GetType()))
            {
                return(false);
            }
            if (typeof(ConfigurationApplicationNode).IsAssignableFrom(configurationNodeToExtend.GetType()))
            {
                return(false);
            }
            if (typeof(ConfigurationSourceSectionNode).IsAssignableFrom(configurationNodeToExtend.GetType()))
            {
                return(false);
            }
            if (typeof(ConfigurationSourceElementNode).IsAssignableFrom(configurationNodeToExtend.GetType()))
            {
                return(false);
            }

            return(true);
        }
Beispiel #26
0
 /// <summary>
 /// Serailize an object to a strings.
 /// </summary>
 /// <param name="objectToSerialize">The object to serialize.</param>
 /// <param name="hierarchy">An <see cref="IConfigurationUIHierarchy"/> object.</param>
 /// <returns>The serailized object to string.</returns>
 public static string SerializeToString(object objectToSerialize, IConfigurationUIHierarchy hierarchy)
 {
     if (objectToSerialize == null)
     {
         return(null);
     }
     if (objectToSerialize is IEnvironmentalOverridesSerializable)
     {
         IEnvironmentalOverridesSerializable serializableInstance = objectToSerialize as IEnvironmentalOverridesSerializable;
         return(serializableInstance.SerializeToString());
     }
     else if (objectToSerialize is ConfigurationNode)
     {
         ConfigurationNode node = objectToSerialize as ConfigurationNode;
         return(CreatePathRelativeToRootNode(node.Path, hierarchy));
     }
     else
     {
         Type          targetType = objectToSerialize.GetType();
         TypeConverter converter  = TypeDescriptor.GetConverter(targetType);
         if (converter != null)
         {
             return(converter.ConvertToInvariantString(objectToSerialize));
         }
     }
     return(null);
 }
Beispiel #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="persistenceProvider"></param>
        /// <param name="stringTbl"></param>
        protected override void SetupControls(IPersistenceProvider persistenceProvider,
                                              Mediator mediator, StringTable stringTbl)
        {
            AtomicReferenceLauncher arl = new AtomicReferenceLauncher();

            arl.Initialize(m_cache, m_obj, m_flid, m_fieldName, persistenceProvider, mediator,
                           DisplayNameProperty,
                           BestWsName);      // TODO: Get better default 'best ws'.
            arl.ConfigurationNode = ConfigurationNode;
            XmlNode deParams = ConfigurationNode.SelectSingleNode("deParams");

            if (XmlUtils.GetOptionalBooleanAttributeValue(
                    deParams, "changeRequiresRefresh", false))
            {
                arl.ChoicesMade += new EventHandler(this.RefreshTree);
            }


            // We don't want to be visible until later, since otherwise we get a temporary
            // display in the wrong place with the wrong size that serves only to annoy the
            // user.  See LT-1518 "The drawing of the DataTree for Lexicon/Advanced Edit draws
            // some initial invalid controls."  Becoming visible when we set the width and
            // height seems to delay things enough to avoid this visual clutter.
            arl.Visible          = false;
            this.Control         = arl;
            arl.ViewSizeChanged += new FwViewSizeChangedEventHandler(this.OnViewSizeChanged);
            AtomicReferenceView view = (AtomicReferenceView)arl.MainControl;

            view.ViewSizeChanged += new FwViewSizeChangedEventHandler(this.OnViewSizeChanged);
        }
Beispiel #28
0
    private static void LoadProtectedPassword(ConfigurationNode node, ConnectionProperties connectionProperties)
    {
        var contains = node.Attributes.TryGetAttributeValue(ConnectionStringKeyword.Password, out string password);

        if (contains)
        {
            var succeeded = false;
            try
            {
                password  = UnprotectPassword(password);
                succeeded = true;
            }
            catch (Exception e)
            {
                Log.Write(LogLevel.Error, e.ToString());
            }

            if (succeeded)
            {
                connectionProperties.Password = new Option <string>(password);

                var dbConnectionStringBuilder = new DbConnectionStringBuilder();
                dbConnectionStringBuilder.ConnectionString = connectionProperties.ConnectionString;
                dbConnectionStringBuilder[ConnectionStringKeyword.Password] = password;
                connectionProperties.ConnectionString = dbConnectionStringBuilder.ConnectionString;
            }
        }
    }
    public void RemoveChildNode(ConfigurationNode childNode)
    {
        Assert.IsNotNull(childNode);
        Assert.IsValidOperation(this == childNode.Parent);

        ChildNodes.Remove(childNode);
        childNode.Parent = null;
    }
Beispiel #30
0
 public ConfigurationMenuItem(ConfigurationNode node, ConfigurationUICommand command)
 {
     this.command = command;
     Shortcut     = command.Shortcut;
     Text         = command.Text;
     this.node    = node;
     this.Enabled = (command.GetCommandState(node) == CommandState.Enabled);
 }
 public void SetFormatter(ConfigurationNode formatters)
 {
     if (formatters == null)
     {
         return;
     }
     formatters.Nodes.ForEach(new Action <ConfigurationNode>(SetFormatterReference));
 }
        protected override void ExecuteCore(ConfigurationNode node)
        {
            AddNewKeyAlgorithmWizard wizard = new AddNewKeyAlgorithmWizard();

            if (wizard.ShowDialog() == DialogResult.OK)
            {
                FileKeyAlgorithmStorageProviderWizard fileWizard = new FileKeyAlgorithmStorageProviderWizard(wizard.KeyAlgorithmPair, ServiceProvider);

                if (fileWizard.ShowDialog() == DialogResult.OK)
                {
                    base.ExecuteCore(node);
                    FileKeyAlgorithmPairStorageProviderNode pairStorageNode = (FileKeyAlgorithmPairStorageProviderNode)ChildNode;
                    pairStorageNode.DpapiSettings = fileWizard.DpapiSettings;
                    pairStorageNode.File = fileWizard.Path;
                }
            }
        }
 protected virtual IUIHierarchy CreateHierarchyAndAddToHierarchyService(ConfigurationNode node, ConfigurationContext configurationContext)
 {
     UIHierarchy hierarchy = new UIHierarchy(node, host, configurationContext);
     hierarchyService.AddHierarchy(hierarchy);
     return hierarchy;
 }
 public void TestInitialize()
 {
     node = new ConfigurationApplicationNode(ConfigurationApplicationFile.FromCurrentAppDomain());
     message = "Test";
     error = new ConfigurationError(node, message);
 }
 public void FixtureSetUp()
 {
     node = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
     message = "Test";
     error = new ConfigurationError(node, message);
 }
 private void OnHierarchyAdded(object sender, HierarchyAddedEventArgs args)
 {
     hierarchyAdded = true;
     nodeAdded = args.UIHierarchy.RootNode;
 }
Beispiel #37
0
 public virtual void ActivateNode(ConfigurationNode node)
 {
     Console.WriteLine("ActivateNode:" + node.Name);
 }
Beispiel #38
0
 /// <summary>
 /// <para>
 /// Initializes a new instance of the <see cref="ConfigurationError"/> class with the <see cref="ConfigurationNode"/> and an error message.
 /// </para>
 /// </summary>
 /// <param name="node"><para>The <see cref="ConfigurationNode"/> object.</para></param>
 /// <param name="message"><para>The. error message.</para></param>
 public ConfigurationError(ConfigurationNode node, string message)
 {
     this.node = node;
     this.message = message;
 }