/// <summary>
		/// Opens the security settings configuration section, builds the design time nodes and adds them to the application node.
		/// </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="rootNode">The root node of the application.</param>
		/// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param>
		protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
		{
			if (null != section)
            {
				rootNode.AddNode(new SecuritySettingsNodeBuilder(serviceProvider, (SecuritySettings)section).Build());
			}
		}
 /// <summary>
 /// Opens the instrumenation section, builds the design time nodes and adds them to the application node.
 /// </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="rootNode">The root node of the application.</param>
 /// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param>
 protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
 {
     if (null != section)
     {
         rootNode.AddNode(new InstrumentationNode((InstrumentationConfigurationSection)section));
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Initialize a new instance of the <see cref="ConfigurationUIHierarchy"/> class.
        /// </summary>
        /// <param name="rootNode">The root node of the hierarchy.</param>
        /// <param name="serviceProvider">The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</param>
        public ConfigurationUIHierarchy(ConfigurationApplicationNode rootNode, IServiceProvider serviceProvider)
        {
            if (rootNode == null)
            {
                throw new ArgumentNullException("rootNode");
            }
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            this.storageSerivce  = new StorageService();
            this.configDomain    = new ConfigurationDesignManagerDomain(serviceProvider);
            this.serviceProvider = serviceProvider;
            nodesByType          = new Dictionary <Guid, NodeTypeEntryArrayList>();
            nodesById            = new Dictionary <Guid, ConfigurationNode>();
            nodesByName          = new Dictionary <Guid, Dictionary <string, ConfigurationNode> >();
            handlerList          = new EventHandlerList();
            this.rootNode        = rootNode;
            this.storageSerivce.ConfigurationFile = this.rootNode.ConfigurationFile;
            this.rootNode.Renamed += new EventHandler <ConfigurationNodeChangedEventArgs>(OnConfigurationFileChanged);
            selectedNode           = rootNode;
            AddNode(rootNode);
            if (null != rootNode.FirstNode)
            {
                rootNode.UpdateHierarchy(rootNode.FirstNode);
            }
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Opens the instrumenation section, builds the design time nodes and adds them to the application node.
 /// </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="rootNode">The root node of the application.</param>
 /// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param>
 protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
 {
     if (null != section)
     {
         rootNode.AddNode(new InstrumentationNode((InstrumentationConfigurationSection)section));
     }
 }
        public void MakeSureThatCurrentAppDomainConfigurationFileIsSetForApplication()
        {
            ConfigurationApplicationFile applicationData = ConfigurationApplicationFile.FromCurrentAppDomain();
            ConfigurationApplicationNode node = new ConfigurationApplicationNode(applicationData);
            ConfigurationUIHierarchy hierarchy = new ConfigurationUIHierarchy(node, ServiceBuilder.Build());

            Assert.AreEqual(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, node.ConfigurationFile);
        }
		public void EnsureThatSettingConfigurationFileUpdatesApplicationDataFile()
		{
			ConfigurationApplicationFile data = ConfigurationApplicationFile.FromCurrentAppDomain();
			ConfigurationApplicationNode node = new ConfigurationApplicationNode(data);
			node.ConfigurationFile = "Foo.config";

			Assert.AreEqual("Foo.config", data.ConfigurationFilePath);
		}
		/// <summary>
		/// Opens the configuration sources section, builds the design time nodes and adds them to the application node.
		/// </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="rootNode">The root node of the application.</param>
		/// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param>
		protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
		{			
			if (null != section)
			{
				ConfigurationSourceSectionNodeBuilder builder = new ConfigurationSourceSectionNodeBuilder(serviceProvider, (ConfigurationSourceSection)section);
				rootNode.AddNode(builder.Build());
			}				
		}
 /// <summary>
 /// Opens the exception handling settings configuration section, builds the design time nodes and adds them to the application node.
 /// </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="rootNode">The root node of the application.</param>
 /// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param>
 protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
 {
     if (null != section)
     {
         ExceptionHandlingSettingsNodeBuilder builder = new ExceptionHandlingSettingsNodeBuilder(serviceProvider, (ExceptionHandlingSettings)section);
         rootNode.AddNode(builder.Build());
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// Opens the configuration sources section, builds the design time nodes and adds them to the application node.
 /// </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="rootNode">The root node of the application.</param>
 /// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param>
 protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
 {
     if (null != section)
     {
         ConfigurationSourceSectionNodeBuilder builder = new ConfigurationSourceSectionNodeBuilder(serviceProvider, (ConfigurationSourceSection)section);
         rootNode.AddNode(builder.Build());
     }
 }
		/// <summary>
		/// Opens the caching configuration from an application configuration file.
		/// </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="rootNode">The <see cref="ConfigurationApplicationNode"/> of the hierarchy.</param>
		/// <param name="section">The caching configuration section or null if no section was found.</param>
		protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
		{
			if (null != section)
			{
				CacheManagerSettingsNodeBuilder builder = new CacheManagerSettingsNodeBuilder(serviceProvider, (CacheManagerSettings)section);
				rootNode.AddNode(builder.Build());
			}
		}
 /// <summary>
 /// Opens the oracle connection configuration section, builds the design time nodes and adds them to the application node.
 /// </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="rootNode">The root node of the application.</param>
 /// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param>
 protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
 {
     if (null != section)
     {
         OracleConnectionNodeBuilder builder = new OracleConnectionNodeBuilder(serviceProvider, (OracleConnectionSettings)section);
         builder.Build();
     }
 }
        public void FindTypeNodeInHierarchy()
        {
            ConfigurationApplicationFile applicationData = ConfigurationApplicationFile.FromCurrentAppDomain();
            ConfigurationApplicationNode applicationNode = new ConfigurationApplicationNode(applicationData);
			IConfigurationUIHierarchy hierarchy = new ConfigurationUIHierarchy(applicationNode, ServiceBuilder.Build());
            MyConfigNode configNode = new MyConfigNode("MyBlock");
            applicationNode.AddNode(configNode);
            ConfigurationNode node = (ConfigurationNode)hierarchy.FindNodeByType(typeof(MyConfigNode));
            
            Assert.IsNotNull(node);
            Assert.AreSame(configNode, node);
        }
        /// <summary>
        /// Sets up the design time objects to represent the configuration for the validation block.
        /// </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="rootNode">The root node of the application.</param>
        /// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.IConfigurationSource"/>.</param>
        protected override void OpenCore(IServiceProvider serviceProvider, 
            ConfigurationApplicationNode rootNode,
            ConfigurationSection section)
        {
            if (null != section)
            {
                ValidationSettingsNodeBuilder builder = new ValidationSettingsNodeBuilder(serviceProvider, (ValidationSettings)section);
                ValidationSettingsNode node = builder.Build();

                SetProtectionProvider(section, node);
                rootNode.AddNode(node);
            }
        }
 /// <summary>
 /// Initializes the database listener and adds it to the logging settings.
 /// </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="rootNode">The root node of the application.</param>
 /// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param>
 protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
 {
     IConfigurationUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);
     foreach (LoggingDatabaseNode loggingDatabaseNode in hierarchy.FindNodesByType(typeof(LoggingDatabaseNode)))
     {
         foreach (ConnectionStringSettingsNode connectionStringNode in hierarchy.FindNodesByType(typeof(ConnectionStringSettingsNode)))
         {
             if (connectionStringNode.Name == ((FormattedDatabaseTraceListenerData)loggingDatabaseNode.TraceListenerData).DatabaseInstanceName)
             {
                 loggingDatabaseNode.DatabaseInstance = connectionStringNode;
                 break;
             }
         }
     }
 }
 /// <summary>
 /// Initializes the symmetric cache store encryption designtime and adds it to the caching settings.
 /// </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="rootNode">The root node of the application.</param>
 /// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param>
 protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
 {
     IConfigurationUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);
     foreach (SymmetricStorageEncryptionProviderNode symmetricStorageEncryptionNode in hierarchy.FindNodesByType(typeof(SymmetricStorageEncryptionProviderNode)))
     {
         foreach (SymmetricCryptoProviderNode symmetricCryptoProviderNode in hierarchy.FindNodesByType(typeof(SymmetricCryptoProviderNode)))
         {
             if (symmetricCryptoProviderNode.Name == symmetricStorageEncryptionNode.symmetricCryptoProviderNodeName)
             {
                 symmetricStorageEncryptionNode.SymmetricInstance = symmetricCryptoProviderNode;
                 break;
             }
         }
     }		
 }		
 /// <summary>
 /// Initializes the security caching store and adds it to the exception settings.
 /// </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="rootNode">The root node of the application.</param>
 /// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param>
 protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, System.Configuration.ConfigurationSection section)
 {
     IConfigurationUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);
     foreach (CachingStoreProviderNode securityCacheNode in hierarchy.FindNodesByType(typeof(CachingStoreProviderNode)))
     {
         foreach (CacheManagerNode cacheManagerNode in hierarchy.FindNodesByType(typeof(CacheManagerNode)))
         {
             if (cacheManagerNode.Name == securityCacheNode.cacheManagerName)
             {
                 securityCacheNode.CacheManager = cacheManagerNode;
                 break;
             }
         }
     }
     base.OpenCore(serviceProvider, rootNode, section);
 }
Exemplo n.º 18
0
 protected override void ExecuteCore(ConfigurationNode node)
 {
     try
     {
         UIService.BeginUpdate();
         ConfigurationApplicationNode appNode   = new ConfigurationApplicationNode(applicationData);
         IConfigurationUIHierarchy    hierarchy = new ConfigurationUIHierarchy(appNode, ServiceProvider);
         ConfigurationUIHierarchyService.AddHierarchy(hierarchy);
         hierarchy.Load();
         UIService.SetUIDirty(hierarchy);
     }
     finally
     {
         UIService.EndUpdate();
     }
 }
 /// <summary>
 /// Initializes the data cache storage and adds it to the caching settings.
 /// </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="rootNode">The root node of the application.</param>
 /// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param>
 protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
 {
     // since logging and exception handling gets loaded before us then we can search for any logging handlers and set the trace source
     IConfigurationUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);
     foreach (DataCacheStorageNode dataCacheStorageNode in hierarchy.FindNodesByType(typeof(DataCacheStorageNode)))
     {
         foreach (ConnectionStringSettingsNode connectionNode in hierarchy.FindNodesByType(typeof(ConnectionStringSettingsNode)))
         {
             if (connectionNode.Name == dataCacheStorageNode.connectionStringName)
             {
                 dataCacheStorageNode.DatabaseInstance = connectionNode;
                 break;
             }
         }
     }
 }
		/// <summary>
		/// Initializes the logging handler and adds it to the exception settings.
		/// </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="rootNode">The root node of the application.</param>
		/// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param>
		protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
		{			
			// since logging and exception handling gets loaded before us then we can search for any logging handlers and set the trace source
			IConfigurationUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);
			foreach (LoggingExceptionHandlerNode handlerNode in hierarchy.FindNodesByType(typeof(LoggingExceptionHandlerNode)))
			{
				foreach (CategoryTraceSourceNode categoryNode in hierarchy.FindNodesByType(typeof(CategoryTraceSourceNode)))
				{
					if (categoryNode.Name == ((LoggingExceptionHandlerData)handlerNode.ExceptionHandlerData).LogCategory)
					{
						handlerNode.LogCategory = categoryNode;						
						break;
					}
				}				
			}			
		}
		protected override void ExecuteCore(ConfigurationNode node)
        {
            try
            {
                UIService.BeginUpdate();
				ConfigurationApplicationNode appNode = new ConfigurationApplicationNode(applicationData);
                IConfigurationUIHierarchy hierarchy = new ConfigurationUIHierarchy(appNode, ServiceProvider);
                ConfigurationUIHierarchyService.AddHierarchy(hierarchy);
				hierarchy.Load();
                UIService.SetUIDirty(hierarchy);
            }
            finally
            {
                UIService.EndUpdate();
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// TODO
        /// </summary>
        /// <param name="node"></param>
        protected override void ExecuteCore(ConfigurationNode node)
        {
            ConfigurationApplicationNode applicationNode = ServiceHelper.GetCurrentRootNode(ServiceProvider);
            string previousConfigurationFile             = applicationNode.ConfigurationFile;

            applicationNode.ConfigurationFile = filePath;
            try
            {
                base.ExecuteCore(node);
            }
            finally
            {
                if (!updateApplicationNode)
                {
                    applicationNode.ConfigurationFile = previousConfigurationFile;
                }
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Initialize a new instance of the <see cref="ConfigurationUIHierarchy"/> class.
        /// </summary>
        /// <param name="rootNode">The root node of the hierarchy.</param>
        /// <param name="serviceProvider">The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</param>
        public ConfigurationUIHierarchy(ConfigurationApplicationNode rootNode, IServiceProvider serviceProvider)
        {
            if (rootNode == null) throw new ArgumentNullException("rootNode");
            if (serviceProvider == null) throw new ArgumentNullException("serviceProvider");

            this.storageSerivce = new StorageService();
            this.configDomain = new ConfigurationDesignManagerDomain(serviceProvider);
            this.serviceProvider = serviceProvider;
            nodesByType = new Dictionary<Guid,NodeTypeEntryArrayList>();
            nodesById = new Dictionary<Guid, ConfigurationNode>();
            nodesByName = new Dictionary<Guid, Dictionary<string, ConfigurationNode>>();
            handlerList = new EventHandlerList();
            this.rootNode = rootNode;
            this.storageSerivce.ConfigurationFile = this.rootNode.ConfigurationFile;
            this.rootNode.Renamed += new EventHandler<ConfigurationNodeChangedEventArgs>(OnConfigurationFileChanged);
            selectedNode = rootNode;
            AddNode(rootNode);
            if (null != rootNode.FirstNode) rootNode.UpdateHierarchy(rootNode.FirstNode);
        }
        public void Open(IServiceProvider serviceProvider)
        {
            IConfigurationSource         configurationSource = GetConfigurationSource(serviceProvider);
            ConfigurationApplicationNode appNode             = ServiceHelper.GetCurrentRootNode(serviceProvider);

            try
            {
                ConfigurationSectionInfo info = GetConfigurationSectionInfo(serviceProvider);
                if (null != info)
                {
                    ConfigurationSection section = configurationSource.GetSection(info.SectionName);
                    OpenCore(serviceProvider, appNode, section);
                }
            }
            catch (Exception e)
            {
                ServiceHelper.LogError(serviceProvider, appNode, e);
            }
        }
		/// <summary>
		/// Opens the connection strings section, builds the design time nodes and adds them to the application node.
		/// </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="rootNode">The root node of the application.</param>
		/// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param>
		protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
		{			
			if (null != section)				
			{
				string defaultDatabase = string.Empty;
				DatabaseSettings databaseSection = DatabaseSettings.GetDatabaseSettings(GetConfigurationSource(serviceProvider));
				if (null != databaseSection) defaultDatabase = databaseSection.DefaultDatabase;				
				DatabaseSectionNode node = rootNode.Hierarchy.FindNodeByType(typeof(DatabaseSectionNode)) as DatabaseSectionNode;
				if (null == node) 
				{
					AddDatabaseSectionNodeCommand dbCmd = new AddDatabaseSectionNodeCommand(serviceProvider, false);
					dbCmd.Execute(rootNode);
					node = dbCmd.ChildNode as DatabaseSectionNode;
					Debug.Assert(node != null);
				}
				ConnectionStringsSectionNodeBuilder builder = new ConnectionStringsSectionNodeBuilder(serviceProvider, (ConnectionStringsSection)section, defaultDatabase, node);
				node.AddNode(builder.Build());
			}
		}
Exemplo n.º 26
0
        /// <summary>
        /// Remove a node from the hierarchy.
        /// </summary>
        /// <param name="node">
        /// The node to remove.
        /// </param>
        public void RemoveNode(ConfigurationNode node)
        {
            string nodeTypeName = node.GetType().FullName;

            nodesByType.Remove(node.Id);
            if (node.Parent != null)
            {
                NodeTypeEntryArrayList childTypes    = nodesByType[node.Parent.Id];
                NodeTypeEntry          entryToRemove = new NodeTypeEntry(node, nodeTypeName);
                if (childTypes.Contains(entryToRemove))
                {
                    childTypes.Remove(entryToRemove);
                    RemoveBaseTypes(node, childTypes);
                }
            }
            node.Hierarchy = null;
            nodesById.Remove(node.Id);
            RemoveNodeByName(node);
            if (node.Id == rootNode.Id)
            {
                rootNode = null;
            }
        }
        private DialogResult GetApplicationFileFromUI()
        {
            ConfigurationApplicationNode node = (ConfigurationApplicationNode)ServiceHelper.GetCurrentRootNode(ServiceProvider);
            SaveFileDialog dialog             = new SaveFileDialog();

            dialog.Filter = Resources.ConfigurationFileDialogFilter;
            dialog.Title  = System.String.Concat(Resources.SaveApplicationCaption, " : ", node.Name);
            IUIService uiService = ServiceHelper.GetUIService(ServiceProvider);

            System.Windows.Forms.DialogResult result = uiService.ShowSaveDialog(dialog);
            Application.DoEvents();
            // we need this because the wait cursor gets set back by the save dialog
            Cursor.Current = Cursors.WaitCursor;
            if (System.Windows.Forms.DialogResult.OK == result)
            {
                DeleteFileIfItExists(dialog.FileName);
                FileName = dialog.FileName;
                node.ConfigurationFile = FileName;
                node.Hierarchy.StorageService.ConfigurationFile = FileName;
                uiService.RefreshPropertyGrid();
            }
            return(result);
        }
Exemplo n.º 28
0
 /// <summary>
 /// Releases the unmanaged resources used by the <see cref="ConfigurationUIHierarchy"/> and optionally releases the managed resources.
 /// </summary>
 public void Dispose()
 {
     if (handlerList != null)
     {
         handlerList.Dispose();
     }
     lock (syncObj)
     {
         while (siteCount > 0)
         {
             ISite site = sites[--siteCount];
             site.Component.Site = null;
             site.Component.Dispose();
         }
         sites        = null;
         handlerList  = null;
         nodesByName  = null;
         nodesById    = null;
         nodesByType  = null;
         rootNode     = null;
         selectedNode = null;
     }
     GC.SuppressFinalize(this);
 }
 /// <summary>
 /// When overriden by a class, allows design managers to perform specific operations when opening configuration.
 /// </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="rootNode">The root node of the application.</param>
 /// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param>
 protected virtual void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
 {
 }
Exemplo n.º 30
0
        private static ConfigurationApplicationNode GetApplicationNode(ConfigurationNode node)
        {
            ConfigurationApplicationNode appNode = (ConfigurationApplicationNode)node.Hierarchy.FindNodeByType(typeof(ConfigurationApplicationNode));

            return(appNode);
        }
Exemplo n.º 31
0
 /// <summary>
 /// Releases the unmanaged resources used by the <see cref="ConfigurationUIHierarchy"/> and optionally releases the managed resources.
 /// </summary>
 public void Dispose()
 {
     if (handlerList != null) handlerList.Dispose();
     lock (syncObj)
     {
         while (siteCount > 0)
         {
             ISite site = sites[--siteCount];
             site.Component.Site = null;
             site.Component.Dispose();
         }
         sites = null;
         handlerList = null;
         nodesByName = null;
         nodesById = null;
         nodesByType = null;
         rootNode = null;
         selectedNode = null;
     }
     GC.SuppressFinalize(this);
 }
 public void ApplicationNodeWithoutPathIsNamedApplicationConfiguration()
 {
     ConfigurationApplicationNode node = new ConfigurationApplicationNode(new ConfigurationApplicationFile());
     Assert.AreEqual("Application Configuration", node.Name);
 }      
Exemplo n.º 33
0
 /// <summary>
 /// Remove a node from the hierarchy.
 /// </summary>
 /// <param name="node">
 /// The node to remove.
 /// </param>
 public void RemoveNode(ConfigurationNode node)
 {
     string nodeTypeName = node.GetType().FullName;
     nodesByType.Remove(node.Id);
     if (node.Parent != null)
     {
         NodeTypeEntryArrayList childTypes = nodesByType[node.Parent.Id];
         NodeTypeEntry entryToRemove = new NodeTypeEntry(node, nodeTypeName);
         if (childTypes.Contains(entryToRemove))
         {
             childTypes.Remove(entryToRemove);
             RemoveBaseTypes(node, childTypes);
         }
     }
     node.Hierarchy = null;
     nodesById.Remove(node.Id);
     RemoveNodeByName(node);
     if (node.Id == rootNode.Id) rootNode = null;
 }
 protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
 {
     rootNode.AddNode(new EnvironmentalOverridesNode());
 }
		public void ConstructNodeWithNullDataThrows()
		{
			ConfigurationApplicationNode node = new ConfigurationApplicationNode(null);
		}
            public TemporaryConfigurationHierarchy(IServiceProvider serviceProvider, string filePath)
            {
                hierarchyService = ServiceHelper.GetUIHierarchyService(serviceProvider);

                previouslySelectedHierarchy = hierarchyService.SelectedHierarchy;

                ConfigurationApplicationFile configurationFile = new ConfigurationApplicationFile(Path.GetDirectoryName(filePath), filePath);
                ConfigurationApplicationNode configurationRootNode = new ConfigurationApplicationNode(configurationFile);
                hierarchy = new ConfigurationUIHierarchy(configurationRootNode, serviceProvider);

                hierarchyService.SelectedHierarchy = hierarchy;


                SaveMergedEnvironmentCommand.UpdateConfigurationSource(hierarchy, filePath);
                hierarchy.Open();
            }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="serviceProvider"></param>
 /// <param name="rootNode"></param>
 /// <param name="section"></param>
 protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
 {
 }