當前位置: 首頁>>代碼示例>>C#>>正文


C# Configuration.ExeConfigurationFileMap類代碼示例

本文整理匯總了C#中System.Configuration.ExeConfigurationFileMap的典型用法代碼示例。如果您正苦於以下問題:C# ExeConfigurationFileMap類的具體用法?C# ExeConfigurationFileMap怎麽用?C# ExeConfigurationFileMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ExeConfigurationFileMap類屬於System.Configuration命名空間,在下文中一共展示了ExeConfigurationFileMap類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: LoadPlugin

        /// <summary>
        /// 導入插件配置文件
        /// </summary>
        /// <param name="plugfile">插件配置文件路徑</param>
        public void LoadPlugin(string plugfile)
        {
            var fileMap = new ExeConfigurationFileMap { ExeConfigFilename = plugfile };
            System.Configuration.Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);

            var unitySection = (UnityConfigurationSection)configuration.GetSection("unity");
            if (unitySection != null)
                container.LoadConfiguration(unitySection);//判斷EntLib的路徑對不對

            var plugininfo = (PluginSectionHandler)configuration.GetSection("plugin");
            if (plugininfo != null)
                plugin.Add(plugininfo);

            if (plugin.defaultdbkey != "")
                database = FactoryDatabase.GetDatabase(plugin.defaultdbkey);
            else
                database = FactoryDatabase.GetDatabase();

            database.PluginName = plugin.name;

            if (plugin.defaultcachekey != "")
                cache = ZhyContainer.CreateCache(plugin.defaultcachekey);
            else
                cache = ZhyContainer.CreateCache();
        }
開發者ID:keep01,項目名稱:efwplus_winformframe,代碼行數:29,代碼來源:ModulePlugin.cs

示例2: GetSparkSettings

		private ISparkSettings GetSparkSettings()
		{
			var map = new ExeConfigurationFileMap {ExeConfigFilename = EnsureFileExists(_arguments.Config)};
			var config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);

			return (ISparkSettings) config.GetSection("spark");
		}
開發者ID:danlash,項目名稱:arq,代碼行數:7,代碼來源:CompileInvoker.cs

示例3: FileConfigurationSourceImplementation

 /// <summary>
 /// Initializes a new instance of <see cref="FileConfigurationSourceImplementation"/>.
 /// </summary>
 /// <param name="refresh">A bool indicating if runtime changes should be refreshed or not.</param>
 /// <param name="configurationFilepath">The path for the main configuration file.</param>
 public FileConfigurationSourceImplementation(string configurationFilepath, bool refresh)
     : base(configurationFilepath, refresh)
 {
     this.configurationFilepath = configurationFilepath;
     this.fileMap = new ExeConfigurationFileMap();
     fileMap.ExeConfigFilename = configurationFilepath;
 }
開發者ID:bnantz,項目名稱:NCS-V2-0,代碼行數:12,代碼來源:FileConfigurationSourceImplementation.cs

示例4: GetServiceEndpoints

        /// <summary>
        /// Gets a collection of <see cref="ServiceEndpoint" />.
        /// </summary>
        /// <param name="serviceConfiguration">The configuration containing endpoint descriptions.</param>
        /// <param name="typeResolver">The type resolver.</param>
        /// <returns>Returns a collection of <see cref="ServiceEndpoint" />.</returns>
        /// <exception cref="System.ArgumentNullException">typeResolver</exception>
        /// <exception cref="System.InvalidOperationException">Invalid service configuration: serviceModel section not found.</exception>
        public IEnumerable<ServiceEndpoint> GetServiceEndpoints(string serviceConfiguration, Func<string, Type> typeResolver)
        {
            if (typeResolver == null)
                throw new ArgumentNullException("typeResolver");

            var configDirectory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(configDirectory);

            var configPath = Path.Combine(configDirectory, "endpoints.config");

            File.WriteAllText(configPath, serviceConfiguration);

            var fileMap = new ExeConfigurationFileMap { ExeConfigFilename = configPath };
            var config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);

            var serviceModelSectionGroup = ServiceModelSectionGroup.GetSectionGroup(config);

            if (serviceModelSectionGroup == null)
                throw new InvalidOperationException("Invalid service configuration: serviceModel section not found.");

            var result = new List<ServiceEndpoint>();

            foreach (ChannelEndpointElement endpointElement in serviceModelSectionGroup.Client.Endpoints)
            {
                if (string.IsNullOrWhiteSpace(endpointElement.Contract))
                    continue;

                var contractType = typeResolver(endpointElement.Contract);
                if (contractType == null)
                    continue;

                var contractDescription = ContractDescription.GetContract(contractType);

                var endpoint = new ServiceEndpoint(contractDescription)
                                   {
                                       Binding =
                                           GetBinding(
                                               endpointElement.BindingConfiguration,
                                               endpointElement.Binding,
                                               serviceModelSectionGroup),
                                       Address =
                                           new EndpointAddress(
                                           endpointElement.Address,
                                           GetIdentity(endpointElement.Identity),
                                           endpointElement.Headers.Headers)
                                   };

                if (!string.IsNullOrEmpty(endpointElement.BehaviorConfiguration))
                    AddBehaviors(endpointElement.BehaviorConfiguration, endpoint, serviceModelSectionGroup);

                endpoint.Name = endpointElement.Contract;

                result.Add(endpoint);
            }

            Directory.Delete(configDirectory, true);

            return result;
        }
開發者ID:mparsin,項目名稱:Elements,代碼行數:68,代碼來源:ServiceConfigurationImporter.cs

示例5: LoadConfigurationFromFile

        public static ProviderConfiguration LoadConfigurationFromFile()
        {
            // Get full file path, and check if it exists
            var file = (Assembly.GetExecutingAssembly().CodeBase + ".config")
                .Replace("file:///", "");

            if (!File.Exists(file)) {
                throw new FileNotFoundException(file + " was not found.");
            }

            // set up a exe configuration map - specify the file name of the DLL's config file
            var map = new ExeConfigurationFileMap();
            map.ExeConfigFilename = file;

            // now grab the configuration from the ConfigManager
            var config = ConfigurationManager.OpenMappedExeConfiguration(map,
                ConfigurationUserLevel.None);

            // now grab the section you're interested in from the opened config -
            // as a sample, I'm grabbing the <appSettings> section
            var section = config.GetSection(SECTION_NAME) as ProviderConfiguration;

            // check for null to be safe, and then get settings from the section
            if (section == null) {
                throw new ConfigurationErrorsException(SECTION_NAME + " section was not found.");
            }

            return section;
        }
開發者ID:brendanhay,項目名稱:Shared,代碼行數:29,代碼來源:ProviderConfiguration.cs

示例6: COBiePropertyMapping

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="configFileName">FileInfo, config file</param>
 public COBiePropertyMapping(FileInfo configFileName ) : this()
 {
     if (configFileName.Exists)
     {
         ConfigFile = configFileName;
         try
         {
             var configMap = new ExeConfigurationFileMap { ExeConfigFilename = ConfigFile.FullName };
             Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
             foreach (string sectionKey in _sectionKeys)
             {
                 var proxy = GetStorageList(sectionKey); //swap to correct path list
                 ConfigurationSection section = config.GetSection(sectionKey);
                 foreach (KeyValueConfigurationElement keyVal in ((AppSettingsSection)section).Settings)
                 {
                     proxy.Add(new AttributePaths(keyVal.Key, keyVal.Value));
                 }
             }
             
         }
         catch (Exception)
         { 
             throw;
         }
     }
     
 }
開發者ID:McLeanBH,項目名稱:XbimExchange,代碼行數:31,代碼來源:COBiePropertyMapping.cs

示例7: InitializeConectionStringsCollection

        private Dictionary<string, string> InitializeConectionStringsCollection(SimpleDataAccessLayer_vs2013Package package, string fileName)
		{
			Project project = package.GetEnvDTE().Solution.FindProjectItem(fileName).ContainingProject;

            var configurationFilename = (from ProjectItem item in project.ProjectItems
                where Regex.IsMatch(item.Name, "(app|web).config", RegexOptions.IgnoreCase)
                select item.FileNames[0]).FirstOrDefault();

            // examine each project item's filename looking for app.config or web.config
            var returnValue = new Dictionary<string, string>();

			if (!string.IsNullOrEmpty(configurationFilename))
			{
				// found it, map it and expose salient members as properties
			    var configFile = new ExeConfigurationFileMap {ExeConfigFilename = configurationFilename};
			    var configuration = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(configFile, ConfigurationUserLevel.None);

				foreach (ConnectionStringSettings connStringSettings in configuration.ConnectionStrings.ConnectionStrings)
				{
					returnValue.Add(connStringSettings.Name, connStringSettings.ConnectionString);
				}
			}

			return returnValue;
		}
開發者ID:rtumaykin,項目名稱:SimpleDataAccessLayer.VS2013,代碼行數:25,代碼來源:MyEditor.cs

示例8: CanDeserializeSerializedCollection

		public void CanDeserializeSerializedCollection()
		{
			LoggingSettings rwLoggingSettings = new LoggingSettings();
			rwLoggingSettings.TraceListeners.Add(new FormattedEventLogTraceListenerData("listener1", CommonUtil.EventLogSourceName, "formatter"));
			rwLoggingSettings.TraceListeners.Add(new SystemDiagnosticsTraceListenerData("listener2", typeof(FormattedEventLogTraceListener), CommonUtil.EventLogSourceName));
			rwLoggingSettings.TraceListeners.Add(new SystemDiagnosticsTraceListenerData("listener3", typeof(XmlWriterTraceListener), "foobar.txt"));

			ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
			fileMap.ExeConfigFilename = "test.exe.config";
			System.Configuration.Configuration rwConfiguration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
			rwConfiguration.Sections.Remove(LoggingSettings.SectionName);
			rwConfiguration.Sections.Add(LoggingSettings.SectionName, rwLoggingSettings);


			File.SetAttributes(fileMap.ExeConfigFilename, FileAttributes.Normal);
			rwConfiguration.Save();

			System.Configuration.Configuration roConfiguration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
			LoggingSettings roLoggingSettings = roConfiguration.GetSection(LoggingSettings.SectionName) as LoggingSettings;

			Assert.AreEqual(3, roLoggingSettings.TraceListeners.Count);

			Assert.IsNotNull(roLoggingSettings.TraceListeners.Get("listener1"));
			Assert.AreEqual(roLoggingSettings.TraceListeners.Get("listener1").GetType(), typeof(FormattedEventLogTraceListenerData));
			Assert.AreSame(roLoggingSettings.TraceListeners.Get("listener1").Type, typeof(FormattedEventLogTraceListener));

			Assert.IsNotNull(roLoggingSettings.TraceListeners.Get("listener2"));
			Assert.AreEqual(roLoggingSettings.TraceListeners.Get("listener2").GetType(), typeof(SystemDiagnosticsTraceListenerData));
			Assert.AreSame(roLoggingSettings.TraceListeners.Get("listener2").Type, typeof(FormattedEventLogTraceListener));

			Assert.IsNotNull(roLoggingSettings.TraceListeners.Get("listener3"));
			Assert.AreEqual(roLoggingSettings.TraceListeners.Get("listener3").GetType(), typeof(SystemDiagnosticsTraceListenerData));
			Assert.AreSame(roLoggingSettings.TraceListeners.Get("listener3").Type, typeof(XmlWriterTraceListener));
		}
開發者ID:ChiangHanLung,項目名稱:PIC_VDS,代碼行數:34,代碼來源:TraceListenerDataCollectionFixture.cs

示例9: OnLoad

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!System.IO.File.Exists(m_connectionStringFileName))
            {
                MessageForm.ShowError("不存在連接字符串文件!");
                this.Close();
                return;
            }
            ExeConfigurationFileMap configMap = new ExeConfigurationFileMap { ExeConfigFilename = m_connectionStringFileName };
            Configuration externalConfig = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);

            int defaultSelectedIndex = -1;
            foreach (ConnectionStringSettings css in externalConfig.ConnectionStrings.ConnectionStrings)
            {
                if (css.Name == "LocalSqlServer")
                    continue;

                m_csss[css.Name] = css;
                cobConnectionStrings.Items.Add(css.Name);

                if (css.Name == Feng.Windows.Utils.SecurityHelper.DataConnectionStringName)
                {
                    defaultSelectedIndex = cobConnectionStrings.Items.Count - 1;
                }
            }

            cobConnectionStrings.SelectedIndex = defaultSelectedIndex;
        }
開發者ID:urmilaNominate,項目名稱:mERP-framework,代碼行數:30,代碼來源:ConnectionStringModifyForm.cs

示例10: CanGetAccessToken

        public void CanGetAccessToken()
        {
            ////var service = new WeiboService(_consumerKey, _consumerSecret);
            var service = new WeiboService(_iphoneConsumerKey, _iphoneConsumerSecret);
            var redirectUri = service.GetRedirectUri("https://api.weibo.com/oauth2/default.html");  //http://www.google.com.hk/
            Assert.NotNull(redirectUri);
            Process.Start(redirectUri.ToString());
            string code = "7f4b0a4ddb364215a4e614732f9e8439";
            var accessToken = service.GetAccessToken(code, GrantType.AuthorizationCode);
            Assert.NotNull(accessToken);
            Assert.IsNotNullOrEmpty(accessToken.Token);

            var fileMap = new ExeConfigurationFileMap {ExeConfigFilename = @"app.config"};
            // relative path names possible

            // Open another config file
            Configuration config =
               ConfigurationManager.OpenMappedExeConfiguration(fileMap,
               ConfigurationUserLevel.None);

            //read/write from it as usual
            ConfigurationSection mySection = config.GetSection("appSettings");
            ////mySection.
            ////    config.SectionGroups.Clear(); // make changes to it

            config.Save(ConfigurationSaveMode.Full);  // Save changes
        }
開發者ID:andyshao,項目名稱:miniweibo,代碼行數:27,代碼來源:WeiboServiceTests.OAuth.cs

示例11: GetScheduleConfig

 private static DailySchedules GetScheduleConfig(string configFile)
 {
     configFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configFile);
     ExeConfigurationFileMap configMap = new ExeConfigurationFileMap { ExeConfigFilename = configFile };
     var configuration = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
     return configuration.GetSection("DailySchedules") as DailySchedules;
 }
開發者ID:ve-interactive,項目名稱:Quartz.ScheduleConfiguration,代碼行數:7,代碼來源:GenerateCronValueTests.cs

示例12: Load

        private bool Load(string file)
        {
            var map = new ExeConfigurationFileMap { ExeConfigFilename = file };
            config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);

            var xml = new XmlDocument();
            using (var stream = new FileStream(file, FileMode.Open, FileAccess.Read))
                xml.Load(stream);

            //var cfgSections = xml.GetElementsByTagName("configSections");

            //if (cfgSections.Count > 0)
            //{
            //    foreach (XmlNode node in cfgSections[0].ChildNodes)
            //    {
            //        var type = System.Activator.CreateInstance(
            //                             Type.GetType(node.Attributes["type"].Value))
            //                             as IConfigurationSectionHandler;

            //        if (type == null) continue;

            //        customSections.Add(node.Attributes["name"].Value, type);
            //    }
            //}

            return config.HasFile;
        }
開發者ID:stevesloka,項目名稱:bvcms,代碼行數:27,代碼來源:ConfigurationProxy.cs

示例13: OpenMappedConfiguration

 public IConfiguration OpenMappedConfiguration(string file)
 {
     ExeConfigurationFileMap exeMap = new ExeConfigurationFileMap();
     exeMap.ExeConfigFilename = file;
     var configuration = ConfigurationManager.OpenMappedExeConfiguration(exeMap, ConfigurationUserLevel.None);
     return new ConfigurationAdapter(configuration);
 }
開發者ID:patrickhuber,項目名稱:BootstrapConfig,代碼行數:7,代碼來源:ApplicationConfigurationProvider.cs

示例14: Load

        public static int display_mode; // 0 for only latest default; 1 for only latest customized style; 2 for slideshow

        public static void Load()
        {
            try
            {
                ExeConfigurationFileMap map = new ExeConfigurationFileMap();
                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                AppSettingsSection app = config.AppSettings;
                version = app.Settings["version"].Value;
                image_folder = app.Settings["image_folder"].Value;
                origin_addr = app.Settings["origin"].Value;
                cdn1_addr = app.Settings["cdn1"].Value;
                cdn2_addr = app.Settings["cdn2"].Value;
                cdn3_addr = app.Settings["cdn3"].Value;
                cdn4_addr = app.Settings["cdn4"].Value;
                source_select = app.Settings["source_select"].Value;
                interval = Convert.ToInt32(app.Settings["interval"].Value);
                max_number = Convert.ToInt32(app.Settings["max_number"].Value);
                autostart = Convert.ToBoolean(app.Settings["autostart"].Value);
                display_mode = Convert.ToInt32(app.Settings["display_mode"].Value);
                return;
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message);
                MessageBox.Show("Configure error!");
                throw (e);
            }
        }
開發者ID:ChrisConstantine,項目名稱:EarthLiveSharp,代碼行數:30,代碼來源:Cfg.cs

示例15: GetConnectionString

        private static string GetConnectionString()
        {
            lock (syncObject)
            {
                string resultConnectionString = "";
                if (string.IsNullOrEmpty(connectionString))
                {
                    if (HttpContext.Current != null)
                    {
                        resultConnectionString = ConfigurationManager.AppSettings["ConnectionString"];
                    }
                    else
                    {
                        string configFileName = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;//"app.config";

                        ExeConfigurationFileMap configFile = new ExeConfigurationFileMap();
                        configFile.ExeConfigFilename = Path.Combine(Environment.CurrentDirectory, configFileName);

                        System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFile, ConfigurationUserLevel.None);
                        if (config.HasFile)
                        {
                            resultConnectionString = config.ConnectionStrings.ConnectionStrings["ConnectionModelsConnectionString"].ConnectionString;// config.AppSettings.Settings["ConnectionString"].Value;
                        }
                        else
                        {
                            throw new Exception(string.Format(Properties.Resources.ConnectionModel_ConfigurationFileError, configFileName));
                        }
                    }
                    connectionString = resultConnectionString;
                }
            }

            return connectionString;
        }
開發者ID:paveltimofeev,項目名稱:SmartPartsFrame,代碼行數:34,代碼來源:ConnectionModel.cs


注:本文中的System.Configuration.ExeConfigurationFileMap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。