remove node from XML - c#

I've below XML in my web.config
<handlers>
<remove name="ChartImageHandler" />
<add name="PageNotFoundhandelarrtf" path="*.rtf" verb="*"
modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\
aspnet_isapi.dll" resourceType="Unspecified" preCondition=
"classicMode,runtimeVersionv2.0,bitness32" />
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="Keyoti_SearchEngine_Web_CallBackHandler_ashx" verb="*" preCondition="integratedMode" path="Keyoti.SearchEngine.Web.CallBackHandler.ashx" type="Keyoti.SearchEngine.Web.CallBackHandler, Keyoti2.SearchEngine.Web, Version=2012.5.12.706, Culture=neutral, PublicKeyToken=58d9fd2e9ec4dc0e" />
<add path="Reserved.ReportViewerWebControl.axd"
verb="*" type="Microsoft.Reporting.WebForms.HttpHandler,
Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken
=b03f5f7f11d50a3a" validate="false" />
</handlers>
And i need to remove last node from this XML for ReportViewer in <handler> section. I first need to find <handler> section than above node should be removed.
I'm using below code but its not working...can you please guide me what's wrong with the below piece of code..
XElement xEmp = XElement.Load(PATH + WEB_CONFIG_PATH);
var empDetails = from emps in xEmp.Elements("handlers")
where emps.Element("path").Equals("Reserved.ReportViewerWebControl.axd")
select emps;
empDetails.First().Remove();
xEmp.Save(#"D:\Employees.xml");

Try to use next code snippet
XElement xEmp = XElement.Load(PATH + WEB_CONFIG_PATH);
var pathToRemove = "Reserved.ReportViewerWebControl.axd";
var empDetails= xEmp.XPathSelectElements("//handlers")
.Descendants()
.First(d => d.Attributes().Any(atr => atr.Name == "path" && atr.Value == pathToRemove));
empDetails.Remove();
xEmp.Save(#"D:\Employees.xml");
If you want to stick with query syntax, you still have to mix it a little bit:
var empDetails = from emps in xEmp.XPathSelectElements("//handlers").Descendants()
where emps.Attributes().Any(atr => atr.Name == "path" && atr.Value == pathToRemove)
select emps;

Deleting the node from XML file is given here: http://www.wrangle.in/topic/asw0zgftjzqr/C-Sharp-tricks-deleting-node-from-xml-fi

I ran this code an it seems to work. Here's what I did . . .
XDocument doc = XDocument.Parse(INPUT_DATA);
XElement handlers = doc.Element("handlers");
IEnumerable<XElement> add = null;
IEnumerable<XElement> pFind = null;
if (handlers != null)
{
add = handlers.Elements();
if (add != null)
{
pFind = (from itm in add
where itm.Attribute("path") != null
&& itm.Attribute("path").Value != null
&& itm.Attribute("path").Value == "Reserved.ReportViewerWebControl.axd"
select itm);
if(pFind != null)
pFind.FirstOrDefault().Remove();
}
}
here is the full tested code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace XDocu
{
class Program
{
static void Main(string[] args)
{
XDocument doc = XDocument.Parse(INPUT_DATA);
XElement handlers = doc.Element("handlers");
IEnumerable<XElement> add = null;
IEnumerable<XElement> pFind = null;
int oldCount = doc.Element("handlers").Elements().Count();
if (handlers != null)
{
add = handlers.Elements();
if (add != null)
{
pFind = (from itm in add
where itm.Attribute("path") != null
&& itm.Attribute("path").Value != null
&& itm.Attribute("path").Value == "Reserved.ReportViewerWebControl.axd"
select itm);
if(pFind != null)
pFind.LastOrDefault().Remove();
}
}
//print it
if (add != null)
Console.WriteLine("Old Count: {0}\nNew Count: {1}", oldCount, add.Count());
}
const string INPUT_DATA =
#"<?xml version=""1.0""?>
<handlers>
<remove name=""ChartImageHandler"" />
<add name=""PageNotFoundhandelarrtf"" path=""*.rtf"" verb=""*""
modules=""IsapiModule"" scriptProcessor=""%windir%\Microsoft.NET\Framework\v2.0.50727\
aspnet_isapi.dll"" resourceType=""Unspecified"" preCondition=
""classicMode,runtimeVersionv2.0,bitness32"" />
<add name=""ChartImageHandler"" preCondition=""integratedMode"" verb=""GET,HEAD"" path=""ChartImg.axd"" type=""System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"" />
<add name=""Keyoti_SearchEngine_Web_CallBackHandler_ashx"" verb=""*"" preCondition=""integratedMode"" path=""Keyoti.SearchEngine.Web.CallBackHandler.ashx"" type=""Keyoti.SearchEngine.Web.CallBackHandler, Keyoti2.SearchEngine.Web, Version=2012.5.12.706, Culture=neutral, PublicKeyToken=58d9fd2e9ec4dc0e"" />
<add path=""Reserved.ReportViewerWebControl.axd""
verb=""*"" type=""Microsoft.Reporting.WebForms.HttpHandler,
Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken
=b03f5f7f11d50a3a"" validate=""false"" />
</handlers>";
}
}
Compiler shows output that removes the item based on your critera correctly, we are left with . . .
<handlers>
<remove name="ChartImageHandler" />
<add name="PageNotFoundhandelarrtf" path="*.rtf" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\ aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="Keyoti_SearchEngine_Web_CallBackHandler_ashx" verb="*" preCondition="integratedMode" path="Keyoti.SearchEngine.Web.CallBackHandler.ashx" type="Keyoti.SearchEngine.Web.CallBackHandler, Keyoti2.SearchEngine.Web, Version=2012.5.12.706, Culture=neutral, PublicKeyToken=58d9fd2e9ec4dc0e" />
</handlers>
That is, with the exclusion of <Add path="Reserved.ReportViewerWebControl.axd" . . . />

Related

How can I get custom action data of a setup project in C#?

I create a windows service and a setup project for my service.
In my windows service I can get my customer action data thinks to this :
Context.Parameters["dbname"]
But I want to access to the value of my customer action data in my service to use it in my project.
Someone have any idea how to do it in c# ?
UPDATE
In my ProjectInstaller :
public ProjectInstaller()
{
InitializeComponent();
}
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
string dbName = Context.Parameters["dbname"];
AppHelper.Save(dbName+" "+ Context.Parameters["targetdir"].ToString());
string xml = Context.Parameters["targetdir"].ToString() + "App.config";
XmlDocument document = new XmlDocument();
document.Load(xml);
XPathNavigator navigator = document.CreateNavigator();
XmlNamespaceManager ns = new XmlNamespaceManager(navigator.NameTable);
foreach (XPathNavigator nav in navigator.Select(#"/configuration.appSettings/add[#key='dbName']"))
{
nav.SetValue(dbName);
}
document.Save(xml);
}
the app.config of my windows service :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="dbName" value="totodb"/>
</appSettings>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v13.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
When I try to install my project I have an error which say that my app.config doesn't exist.
This is working for me. You will need to replace ConsoleApp2 with your output filename.
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
string dbName = Context.Parameters["dbname"].ToString();
string xml = Context.Parameters["name"].ToString() + "ConsoleApp2.exe.config";
XmlDocument document = new XmlDocument();
document.Load(xml);
XmlNode dbNameNode = document.SelectSingleNode("//configuration/appSettings/add[#key='dbName']");
dbNameNode.Attributes["value"].Value = dbName;
document.Save(xml);
}
and my custom action data is:
/name="[TARGETDIR]\" /dbname=[EDITA1]
You can add MessageBox and things in to aid debugging.

How to create a custom app.config with just one extra entry

I want my app.config file to be something like
<configSections>
<section name ="RegCompany" type =""/>
</configSections>
<RegCompany>
<Company name="Tata Motors" code="Tata"/>
<SomethingElse url="someuri"/>
</RegCompany>
Any idea how to do this? I want to get the values defined here through my code.
For simple values like this, there is an easier solution than the one in the duplicate questions.
Config:
<configSections>
<section name="RegCompany" type="System.Configuration.NameValueSectionHandler"/>
</configSections>
<RegCompany>
<add key="CompanyName" value="Tata Motors" />
<add key="CompanyCode" value="Tata" />
<add key="CompanyUrl" value="example.com" />
</RegCompany>
Code:
var section = ConfigurationManager.GetSection("RegCompany") as NameValueCollection;
if (section == null) {
throw new InvalidOperationException("Unknown company");
}
var company = section["CompanyName"];
var code = section["CompanyCode"];
var url = section["CompanyUrl"];

Formatter not set in custom trace listener for EnterpriseLibrary logging

I have created a custom trace listener for the EnterpriseLibrary logging block, but the Formatter property is always null.
This is the code:
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Logging.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners;
using System;
using System.Diagnostics;
namespace test {
[ConfigurationElementType(typeof(CustomTraceListenerData))]
public class TestTraceListener : CustomTraceListener {
public override void Write(string message) {
Console.Write(message);
}
public override void WriteLine(string message) {
Console.WriteLine(message);
}
public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data) {
LogEntry entry = data as LogEntry;
if (entry != null) {
if (Formatter != null) {
string formatted = Formatter.Format(entry);
WriteLine(formatted);
} else {
WriteLine(entry.Message);
}
} else {
base.TraceData(eventCache, source, eventType, id, data);
}
}
}
class Program {
static void Main(string[] args) {
Logger.SetLogWriter(new LogWriterFactory().Create());
LogEntry entry = new LogEntry("This is a test", "General", 0, 0, TraceEventType.Information, null, null);
Logger.Write(entry);
}
}
}
And this is the configuration file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="loggingConfiguration"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
requirePermission="true" />
</configSections>
<loggingConfiguration name="logging" tracingEnabled="true" defaultCategory="General">
<listeners>
<add name="Console Trace Listener"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.SystemDiagnosticsTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
formatter="Simple Formatter"
type="test.TestTraceListener, test"
traceOutputOptions="DateTime, Timestamp, ThreadId" />
</listeners>
<formatters>
<add name="Simple Formatter"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
template="{timestamp(local:dd/MM/yy HH:mm:ss.fff)} [{severity}]: {message}" />
</formatters>
<categorySources>
<add switchValue="Information" name="General">
<listeners>
<add name="Console Trace Listener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="Warning" name="Logging Errors & Warnings" />
</specialSources>
</loggingConfiguration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
</configuration>
If I understood correctly, my listener should have the "Simple Formatter" formatter that I declared in the configuration file in its Formatter property, but this is not the case.
What am I missing?
I solved the problem with the Enterprise Library Configuration Tool (I could make it work for VS 2015 following the instructions here: Does Enterprise Library 6 work with Visual Studio 2013 and/or 2015?).
The problem was a wrong value of the listenerDataType attribute, the XML declaration of the listener should have been the following:
<add listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.CustomTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
type="test.TestTraceListener, test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
name="Console Trace Listener"
formatter="Simple Formatter" />

NancyFx - Razor Compilation Error

Error while compiling view
Error compiling template: views/devices.cshtml
Errors:
[CS0234] Line: 3 Column: 27 - The type or namespace name 'Services' does
not exist in the namespace 'Rioxo.Companion'
(are you missing an assembly reference?)
Details:
#using System
#using System.Collections.Generic
#using Rioxo.Companion.Services <---
web.config
<razor disableAutoIncludeModelNamespace="false">
<assemblies>
<add assembly="Server32" />
<add assembly="Rioxo.Companion.Services" />
</assemblies>
<namespaces>
<add namespace="Rioxo.Companion.Server" />
<add namespace="Rioxo.Companion.Services" />
</namespaces>
</razor>
What could be the problem here?
Edit: the original problem was solved by putting the configuration in the correct .config file, for future reference, adding here you can also implement your own IRazorConfiguration which Nancy will automatically pick up, this means you don't need any .config registraion at all.
Example:
public class RazorConfig : IRazorConfiguration
{
public IEnumerable<string> GetAssemblyNames()
{
yield return "MyWebsite.Web";
yield return "MyWebsite.Models";
yield return "Sandra.SimpleValidator";
yield return "ServiceStack.Text";
}
public IEnumerable<string> GetDefaultNamespaces()
{
yield return "Nancy.Validation";
yield return "System.Globalization";
yield return "System.Collections.Generic";
yield return "System.Linq";
yield return "MyWebsite.Web";
yield return "MyWebsite.Models";
yield return "MyWebsite.Web.ViewModels";
yield return "MyWebsite.Web.Helpers.RazorHelpers";
}
public bool AutoIncludeModelNamespace
{
get { return true; }
}
}
Original Answer:
I don't actually know what Rioxo is and their site doesn't seem to have a download.
So I'm taking a shot here and assuming its because you haven't referenced the assembly by its name properly.
I think the name is probably Rioxo.Companion or Rioxo
So updating the <assemblies> section to something like:
<razor disableAutoIncludeModelNamespace="false">
<assemblies>
<add assembly="Server32" />
<add assembly="Rioxo" />
</assemblies>
<namespaces>
<add namespace="Rioxo.Companion.Server" />
<add namespace="Rioxo.Companion.Services" />
</namespaces>
</razor>
or
<razor disableAutoIncludeModelNamespace="false">
<assemblies>
<add assembly="Server32" />
<add assembly="Rioxo.Companion" />
</assemblies>
<namespaces>
<add namespace="Rioxo.Companion.Server" />
<add namespace="Rioxo.Companion.Services" />
</namespaces>
</razor>
Should fix the issue.

Log messages going to previously created log file

I am using enterprise library 5.0 logging in my asp.net site,
My web.config file is as follows:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true"/>
</configSections>
<loggingConfiguration name="FlatFileLogging" tracingEnabled="true"
defaultCategory="General">
<listeners>
<add name="Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="C:\Logs\2013-06-28 14-21-53.log" header="" footer=""
formatter="Text Formatter" traceOutputOptions="DateTime" />
</listeners>
<formatters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
template="{timestamp}, {severity}, {message}" name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="Flat File Trace Listener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Flat File Trace Listener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
<appSettings/>
<connectionStrings/>
<system.web>
<compilation debug="true" targetFramework="4.0">
</compilation>
<authentication mode="Windows"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web>
</configuration>
I am changing log file path using following function:
public static void SetLogFilePath(string filePath)
{
//string logdirectory = AppDomain.CurrentDomain.BaseDirectory + "Logs\\";
//if (!Directory.Exists(logdirectory))
// Directory.CreateDirectory(logdirectory);
//logFilePath = logdirectory + (string.IsNullOrWhiteSpace(txtBatchName.Text) ? "" : (txtBatchName.Text + " ")) + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".log";
if (!File.Exists(filePath))
File.Create(filePath);
ConfigurationFileMap objConfigPath = new ConfigurationFileMap();
// App config file path.
string appPath = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
objConfigPath.MachineConfigFilename = appPath;
Configuration entLibConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
LoggingSettings loggingSettings = (LoggingSettings)entLibConfig.GetSection(LoggingSettings.SectionName);
TraceListenerData traceListenerData = loggingSettings.TraceListeners.Get("Flat File Trace Listener");
FlatFileTraceListenerData objFlatFileTraceListenerData = traceListenerData as FlatFileTraceListenerData;
objFlatFileTraceListenerData.FileName = filePath;
entLibConfig.Save();
}
Whenever I change log file path and send log messages to file, the logs do not go to newly created file. Log messages go to previously set file path. seems that new setting is not reflecting immediately.
string path = "C:\\Logs\\" + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".log";
SetLogFilePath(path);
Logger.Write(message, "General", 1, 0, System.Diagnostics.TraceEventType.Information);
How to refresh the new settings to code immediately?
How do you define "immediately"? If you mean in the middle of the executing request then I don't think you can do that via configuration since the configuration will not be refreshed for that request.
Here's an implementation that seems to work for me based on the blog post Enterprise Library Programmatic Configuration. I don't write the config change back to disk but change it in memory instead.
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
EnterpriseLibraryContainer.Current.GetInstance<LogWriter>()
.Write("test", "General");
string path = "C:\\Logs\\anotherlogfile.log";
SetLogFilePath(path);
EnterpriseLibraryContainer.Current.GetInstance<LogWriter>()
.Write("Another test", "General");
}
public void SetLogFilePath(string filePath)
{
ConfigurationFileMap objConfigPath = new ConfigurationFileMap();
// App config file path.
string appPath = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
objConfigPath.MachineConfigFilename = appPath;
Configuration entLibConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
LoggingSettings loggingSettings = (LoggingSettings)entLibConfig.GetSection(LoggingSettings.SectionName);
TraceListenerData traceListenerData = loggingSettings.TraceListeners.Get("Flat File Trace Listener");
FlatFileTraceListenerData objFlatFileTraceListenerData = traceListenerData as FlatFileTraceListenerData;
objFlatFileTraceListenerData.FileName = filePath;
IUnityContainer container = new UnityContainer();
container.AddNewExtension<EnterpriseLibraryCoreExtension>();
// Configurator will read Enterprise Library configuration
// and set up the container
UnityContainerConfigurator configurator = new UnityContainerConfigurator(container);
var loggingXmlConfigSource = new SerializableConfigurationSource();
loggingXmlConfigSource.Add(LoggingSettings.SectionName, loggingSettings);
// Configure the container with our own custom logging
EnterpriseLibraryContainer.ConfigureContainer(configurator, loggingXmlConfigSource);
// Wrap in ServiceLocator
IServiceLocator locator = new UnityServiceLocator(container);
// Release lock(s) on existing file(s)
EnterpriseLibraryContainer.Current.GetInstance<LogWriter>().Dispose();
// And set Enterprise Library to use it
EnterpriseLibraryContainer.Current = locator;
}
}
public class SerializableConfigurationSource : IConfigurationSource
{
Dictionary<string, ConfigurationSection> sections = new Dictionary<string, ConfigurationSection>();
public SerializableConfigurationSource()
{
}
public ConfigurationSection GetSection(string sectionName)
{
ConfigurationSection configSection;
if (sections.TryGetValue(sectionName, out configSection))
{
SerializableConfigurationSection section = configSection as SerializableConfigurationSection;
if (section != null)
{
using (StringWriter xml = new StringWriter())
using (XmlWriter xmlwriter = System.Xml.XmlWriter.Create(xml))
{
section.WriteXml(xmlwriter);
xmlwriter.Flush();
MethodInfo methodInfo = section.GetType().GetMethod("DeserializeSection", BindingFlags.NonPublic | BindingFlags.Instance);
methodInfo.Invoke(section, new object[] { XDocument.Parse(xml.ToString()).CreateReader() });
return configSection;
}
}
}
return null;
}
public void Add(string sectionName, ConfigurationSection configurationSection)
{
sections[sectionName] = configurationSection;
}
public void AddSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler)
{
throw new NotImplementedException();
}
public void Remove(string sectionName)
{
sections.Remove(sectionName);
}
public void RemoveSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler)
{
throw new NotImplementedException();
}
public event EventHandler<ConfigurationSourceChangedEventArgs> SourceChanged;
public void Dispose()
{
}
}

Categories

Resources