本文整理汇总了C#中System.Configuration.Configuration.GetSectionGroup方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.GetSectionGroup方法的具体用法?C# Configuration.GetSectionGroup怎么用?C# Configuration.GetSectionGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Configuration.Configuration
的用法示例。
在下文中一共展示了Configuration.GetSectionGroup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSectionGroup
public static SerializationSectionGroup GetSectionGroup (ConfigurationType config)
{
var ret = (SerializationSectionGroup) config.GetSectionGroup ("system.runtime.serialization");
if (ret == null)
throw new SystemException ("Internal configuration error: section 'system.runtime.serialization' was not found.");
return ret;
}
示例2: GetSectionGroup
static public TransactionsSectionGroup GetSectionGroup(Configuration config)
{
if (config == null)
{
throw new ArgumentNullException("config");
}
return (TransactionsSectionGroup)config.GetSectionGroup(ConfigurationStrings.SectionGroupName);
}
示例3: GetSectionGroup
public static ServiceModelSectionGroup GetSectionGroup (
ConfigurationType config)
{
ServiceModelSectionGroup ret = (ServiceModelSectionGroup) config.GetSectionGroup ("system.serviceModel");
if (ret == null)
throw new SystemException ("Internal configuration error: section 'system.serviceModel' was not found.");
return ret;
}
示例4: GetSetting
private static SettingElement GetSetting(Configuration config, string name)
{
var group = config.GetSectionGroup("applicationSettings");
var section = group.Sections.Get("Toggl.Tests.Properties.Settings") as ClientSettingsSection;
var settings = section.Settings;
var setting = settings.Get(name);
return setting;
}
示例5: DeclareSection
// Declares the section handler of a given section in its section group, if a declaration isn't already
// present.
private void DeclareSection(Configuration config, string sectionName) {
ConfigurationSectionGroup settingsGroup = config.GetSectionGroup(UserSettingsGroupName);
if (settingsGroup == null) {
//Declare settings group
ConfigurationSectionGroup group = new UserSettingsGroup();
config.SectionGroups.Add(UserSettingsGroupName, group);
}
settingsGroup = config.GetSectionGroup(UserSettingsGroupName);
Debug.Assert(settingsGroup != null, "Failed to declare settings group");
if (settingsGroup != null) {
ConfigurationSection section = settingsGroup.Sections[sectionName];
if (section == null) {
section = new ClientSettingsSection();
section.SectionInformation.AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToLocalUser;
section.SectionInformation.RequirePermission = false;
settingsGroup.Sections.Add(sectionName, section);
}
}
}
示例6: AddSection
/// <summary>
///
/// </summary>
/// <param name="pConfiguration">Configuration del app.config</param>
/// <param name="pSectionName">Seccion</param>
/// <param name="pSectionGroupName">Grupo</param>
internal static void AddSection(Configuration pConfiguration, String pSectionName,String pSectionGroupName,String pSettingTemplateName)
{
ConfigurationSectionGroup wConfigurationSectionGroup =null;
SettingElement wSettingElement = null;
XmlDocument doc = new XmlDocument();
XmlNode xmlValue = doc.CreateNode(XmlNodeType.Element, "value", String.Empty);
ConfigurationSectionCollection wSections = null;
if (pSectionGroupName.Length == 0)
{
AddSectionFromAssembly(pConfiguration, pSectionName);
return;
}
else
{
wConfigurationSectionGroup = pConfiguration.GetSectionGroup(pSectionGroupName);
if (wConfigurationSectionGroup == null)
wConfigurationSectionGroup = AddSectionGroup(pConfiguration, pSectionGroupName);
wSections = wConfigurationSectionGroup.Sections;
}
if (wSections.Get(pSectionName) != null) return;
ClientSettingsSection wClientSettingsSection = new ClientSettingsSection();
wClientSettingsSection.SectionInformation.RequirePermission = false;
wClientSettingsSection.SectionInformation.ForceSave = true;
#region Settings
Dictionary<String, String> wSettings = TemplateProvider.GetSettingDic(pSettingTemplateName);
if (wSettings != null)
{
foreach (KeyValuePair<string, string> seting in wSettings)
{
wSettingElement = new SettingElement();
wSettingElement.Name = seting.Key;
xmlValue.InnerXml = seting.Value;
wSettingElement.Value.ValueXml = xmlValue.Clone();
wClientSettingsSection.Settings.Add(wSettingElement);
}
}
#endregion
wSections.Add(pSectionName, wClientSettingsSection);
}
示例7: GetSectionGroup
static public NetSectionGroup GetSectionGroup(Configuration config)
{
if (config == null)
throw new ArgumentNullException("config");
return config.GetSectionGroup(ConfigurationStrings.SectionGroupName) as NetSectionGroup;
}
示例8: RemoveSection
/// <summary>
/// Elimina una seccion de la Configuration / applicationSettings
/// </summary>
/// <param name="pConfiguration">Configuration App.Config</param>
/// <param name="pSectionName">Nombre de la seccion</param>
internal static void RemoveSection(Configuration pConfiguration, String pSectionName)
{
ConfigurationSectionGroup wSectionGroup = pConfiguration.GetSectionGroup("applicationSettings");
ConfigurationSection wSection = wSectionGroup.Sections.Get(pSectionName);//ConfigurationSection wSection = pConfiguration.GetSection("applicationSettings/" + pSectionName);
wSection.SectionInformation.ForceSave = true;
pConfiguration.GetSectionGroup("applicationSettings").Sections.Remove(pSectionName);
pConfiguration.Sections.Remove(pSectionName);
}
示例9: Add_SettingInSection
internal static void Add_SettingInSection(Configuration pConfiguration,
String pSectionName,
String pSectionGroupName,
String pSettingName,String settingValue)
{
ConfigurationSectionGroup wConfigurationSectionGroup = null;
//SettingElement wSettingElement = null;
XmlDocument doc = new XmlDocument();
XmlNode xmlValue = doc.CreateNode(XmlNodeType.Element, "value", String.Empty);
ConfigurationSectionCollection wSections = null;
if (pSectionGroupName.Length == 0)
{
AddSectionFromAssembly(pConfiguration, pSectionName);
return;
}
else
{
wConfigurationSectionGroup = pConfiguration.GetSectionGroup(pSectionGroupName);
if (wConfigurationSectionGroup == null)
wConfigurationSectionGroup = AddSectionGroup(pConfiguration, pSectionGroupName);
wSections = wConfigurationSectionGroup.Sections;
}
ConfigurationSection wConfigurationSection = wSections.Get(pSectionName);
ClientSettingsSection wClientSettingsSection = (ClientSettingsSection)wConfigurationSection;
wClientSettingsSection.SectionInformation.RequirePermission = false;
wClientSettingsSection.SectionInformation.ForceSave = true;
#region Settings
//wClientSettingsSection.Settings.Get(pSettingName);
SettingElement wSettingElement = new SettingElement();
wSettingElement.Name = pSettingName;
xmlValue.InnerXml = settingValue;
wSettingElement.Value.ValueXml = xmlValue.Clone();
wClientSettingsSection.Settings.Add(wSettingElement);
#endregion
}
示例10: GetSettingElementCollection
/// <summary>
/// Gets the <see cref="SettingElementCollection"/> for the specified section name within
/// the specified configuration.
/// </summary>
/// <param name="config">The <see cref="Configuration"/> object.</param>
/// <param name="sectionName">The settings section name.</param>
/// <returns>
/// A <see cref="SettingElementCollection"/> for the section, or an empty section if not found.
/// </returns>
private static SettingElementCollection GetSettingElementCollection(Configuration config, string sectionName)
{
var userSettings = config.GetSectionGroup("userSettings");
if (userSettings == null)
{
userSettings = new UserSettingsGroup();
config.SectionGroups.Add("userSettings", userSettings);
}
var section = userSettings.Sections.Get(sectionName) as ClientSettingsSection;
if (section == null)
{
section = new ClientSettingsSection();
userSettings.Sections.Add(sectionName, section);
}
return section.Settings;
}
示例11: RemoveSettingsValues
public static void RemoveSettingsValues(SystemConfiguration configuration, Type settingsClass)
{
var sectionPath = new ConfigurationSectionPath(settingsClass, SettingScope.Application);
ConfigurationSectionGroup group = configuration.GetSectionGroup(sectionPath.GroupPath);
if (group != null)
group.Sections.Remove(sectionPath.SectionName);
sectionPath = new ConfigurationSectionPath(settingsClass, SettingScope.User);
group = configuration.GetSectionGroup(sectionPath.GroupPath);
if (group != null)
group.Sections.Remove(sectionPath.SectionName);
configuration.Save(ConfigurationSaveMode.Minimal, true);
}
示例12: GenerateEnvironmentConfiguration
private static void GenerateEnvironmentConfiguration(Configuration envConfig, Configuration mainConfig)
{
// Connection strings
foreach (ConnectionStringSettings connectionString in envConfig.ConnectionStrings.ConnectionStrings)
{
if (connectionString.Name == "LocalSqlServer") continue;
mainConfig.ConnectionStrings.ConnectionStrings[connectionString.Name].ConnectionString =
connectionString.ConnectionString;
}
// app settings
foreach (KeyValueConfigurationElement setting in envConfig.AppSettings.Settings)
{
mainConfig.AppSettings.Settings[setting.Key].Value = setting.Value;
}
// applicationSettings
var group = envConfig.GetSectionGroup("applicationSettings");
if (group != null)
{
foreach (ConfigurationSection section in group.Sections)
{
if (!(section is ClientSettingsSection)) continue;
var s = (ClientSettingsSection)section;
var mainGroup = mainConfig.GetSectionGroup("applicationSettings");
if (mainGroup == null)
{
mainConfig.SectionGroups.Add("applicationSettings", group);
break;
}
var mainS = mainGroup.Sections.Get(s.SectionInformation.Name) as ClientSettingsSection;
if (mainS == null)
{
mainGroup.Sections.Add(s.SectionInformation.Name, s);
}
else
{
foreach (SettingElement setting in s.Settings)
{
var toRemove = mainS.Settings.Get(setting.Name);
if (toRemove != null)
{
mainS.Settings.Remove(toRemove);
}
mainS.Settings.Add(setting);
}
}
}
}
mainConfig.Save();
}
示例13: GetSection
/// ------------------------------------------------------------------------------------
/// <summary>
/// Gets the section <paramref name="sectionName"/> in the section group "userSettings".
/// </summary>
/// ------------------------------------------------------------------------------------
private static ClientSettingsSection GetSection(Configuration config, string sectionName,
string sectionGroup = "userSettings")
{
var userSettingsGroup = config.GetSectionGroup(sectionGroup);
if (userSettingsGroup == null)
{
userSettingsGroup = new ConfigurationSectionGroup();
config.SectionGroups.Add(sectionGroup, userSettingsGroup);
}
var section = userSettingsGroup.Sections[sectionName] as ClientSettingsSection;
if (section == null)
{
section = new ClientSettingsSection();
userSettingsGroup.Sections.Add(sectionName, section);
}
return section;
}
示例14: Instance
public static SmtpMailer Instance(Configuration configuration)
{
_mailSettings = configuration.GetSectionGroup("system.net/mailSettings") as MailSettingsSectionGroup;
return _instance ?? (_instance = new SmtpMailer());
}
示例15: SetDisUrl
//修改applicationSettings
private void SetDisUrl(WsConfig wsconfig, Configuration config)
{
ApplicationSettingsGroup appSection = config.GetSectionGroup("applicationSettings") as ApplicationSettingsGroup;
ClientSettingsSection css = appSection.Sections[0] as ClientSettingsSection;
SettingElement se = css.Settings.Get("CM_EDI_Service_DocumentManagement_WSTosEdiInterface_WSTosEdiInterface");
if (se != null)
{
css.Settings.Remove(se);
se.Value.ValueXml.InnerXml = string.Format("http://{0}:{1}/Service.asmx", IISWorker.GetIp(), wsconfig.DISInterAPIServerSitePort);
css.Settings.Add(se);
}
se = css.Settings.Get("CM_CTOS_BLL_BLLWebProxy_WSEdiTosInterface_WsEdiTosInterface");
if (se != null)
{
css.Settings.Remove(se);
se.Value.ValueXml.InnerXml = string.Format("http://{0}:{1}/Service.asmx", IISWorker.GetIp(), wsconfig.EdiServerSitePort);
css.Settings.Add(se);
}
se = css.Settings.Get("TosPACSAddress");
if (se != null)
{
css.Settings.Remove(se);
se.Value.ValueXml.InnerXml = string.Format("http://{0}:{1}/Service.asmx", IISWorker.GetIp(), wsconfig.RpcDomainPort);
css.Settings.Add(se);
}
se = css.Settings.Get("CM_CTOS_BLL_BLLWebProxy_WSBaseDataSearchForBilling_WSBaseDataSearch");
if (se != null)
{
string url = string.IsNullOrEmpty(wsconfig.BillingDataServerSitePath) ? se.Value.ValueXml.InnerText = wsconfig.BillingDataServerSite :string.Format("http://{0}:{1}/{2}/Service.asmx", IISWorker.GetIp(), wsconfig.BillingDataServerSitePort, wsconfig.BillingDataServerSite);
css.Settings.Remove(se);
se.Value.ValueXml.InnerXml = url;
css.Settings.Add(se);
}
se = css.Settings.Get("CM_CTOS_BLL_BLLWebProxy_WSBillingExternalInterface_WSBillingExternalInterface");
if (se != null)
{
string url = string.IsNullOrEmpty(wsconfig.BillingInternelServerSitePath) ? se.Value.ValueXml.InnerText = wsconfig.BillingInternelServerSite :string.Format("http://{0}:{1}/{2}/Service.asmx", IISWorker.GetIp(), wsconfig.BillingInternelServerSitePort);
css.Settings.Remove(se);
se.Value.ValueXml.InnerXml = url;
css.Settings.Add(se);
}
}