当前位置: 首页>>代码示例>>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;未经允许,请勿转载。