Windows Workflow Foundation 3


Custom Config Sections in .net 2.0


I have a custom config section and it is implemented using .Net 1.1. I find that doing the same thing in .Net 2.0 is much cumbersome and is less flexible.For example to implement a config section, you need to do the following in 1.1.
Code Snippet
Here is my custom config section.
<EMMSConfiguration type="Namespace.Class,Dll"><Application.Configuration><ImageQueueConfiguration><ImageQueue name="ImageQueueType1"><RootPath>C:\Repository\ImageQueueType1\</RootPath><SourcePath>C:\Repository\ImageQueueType1\Source\</SourcePath><LogTimings>1</LogTimings><RemoveBlankPages>1</RemoveBlankPages></ImageQueue><ImageQueue name="ScannerQueue"><RootPath>C:\Repository\LocalScanner\</RootPath><SourcePath>C:\Repository\LocalScanner\Source\</SourcePath><LogTimings>1</LogTimings><FileWriteDelay>1</FileWriteDelay><FileWaitingTimeout>30</FileWaitingTimeout><DriverInterface>TWAIN</DriverInterface><RemoveBlankPages>1</RemoveBlankPages></ImageQueue></ImageQueueConfiguration></Application.Configuration></EMMSConfiguration>
And the handler.
public class ConfigurationHandler : System.Configuration.IConfigurationSectionHandler{public object Create(Object parent, object configContext, XmlNode section){Type type = System.Type.GetType(section.Attributes["type"].Value);object[] parameters = { section };//call the configuration object's constructorobject configObject = null;try{configObject = Activator.CreateInstance(type, parameters);}catch (Exception ex){string x = ex.Message;return null;}return configObject;}}
The Handler creates and cahes the following class.
public class ConfigManager{private XmlNode configurationData;public ConfigManager(XmlNode sections){configurationData = sections.SelectSingleNode("Application.Configuration");}public ImageQueueConfiguration GetImageQueueConfig(string qName){XmlNode imageQueueNode = configurationData.SelectSingleNode("ImageQueueConfiguration/ImageQueue[#name='" + qName + "']");ImageQueueConfiguration iq = new ImageQueueConfiguration(imageQueueNode);return iq;}}
And here is the class that exposes the proeprties of the config section.
public class ImageQueueConfiguration{public string QueueName;............other properties............
public ImageQueueConfiguration(XmlNode imageQueueNode){QueueName = imageQueueNode.SelectSingleNode("#name").InnerText; ; ............other properties............
}
}
It is very flexible. From the config XML, the ConfigManager can do any kind of manipulation to get the required data.I went through some examples on how to do the same in 2.0.http://aspnet.4guysfromrolla.com/articles/032807-1.aspxhttp://dotnetslackers.com/articles/customconfiguration/Custom_Configuration_Collections.aspx
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;margin-bottom:.0001pt;font-size:12.0pt;font-family:'Times New Roman';}
#page Section1
{size:8.5in 11.0in;margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
{page:Section1;}
To implement a custom section with collections, I have to implement: 1. ConfigurationElement 2. ConfigurationElementCollection And it does not allow complex XML configuration too. (with inner child nodes)In 1.1, to add another custom section, I just have to add another 'lean' class and add a member to the 'ConfigManager'.Is there a way for me to get the raw XML and do the things in my own way in 2.0?Thanks in advance.
I think Sung means this forum
http://forums.msdn.microsoft.com/en-US/netfxbcl/threads/
 
Hi,
 
   This is the wrong forum for config questions.  You should post this question in the BCL forum,
 
http://ddweb/answerme/Questions.aspx?forumID=39
 
Sung Hon
 
I think Sung means this forum
http://forums.msdn.microsoft.com/en-US/netfxbcl/threads/
 

Related Links

Customizing work flow
Generating ruleset in runtime
WorkflowPersistence question
problem of cross-threading.
Terminating host leaves status in limbo
Runtime change in workflow
Beta2 Workflow Error
Changing which workflow items are available when modifying at runtime
ExpenseReport Sample Cancle Approval Question
Problem with sendmail Activity
Global Run Time Variable
To use dependency properties or not
OwnershipTimeoutSeconds
Problem in WorkflowRuntime.WorkflowCompleted event
HandleExternalEvent Problem
WWF with .NET compact framework 2.0

Categories

MSDN
Using Forums
Windows Phone Development
Visual FoxPro
Internet Explorer Deve...
Microsoft Sync Framework
Smart Device Development
SQL Server (Pre-release)
Office Live Development
Open Specifications
Project Server
Microsoft Atlas API: D...
Expression
Archived Forums I-L
Archived Forums T-U
Skype for Business
Software Entwicklung f...
Announcements for all ...
Off-Topic Posts (Do No...
Visual Studio LightSwi...
Visual Studio Diagnost...
Visual Studio Tools fo...
Application Insights (AI)
Submitting and Publish...
App & Ad Unit Management
Developing Windows Des...
Media Foundation Devel...
Application Security f...
Windows Desktop Perfmo...
Excel for Developers
Open XML Format SDK
SharePoint 2010 - Usin...
Azure Virtual Machines
Azure Log Analytics
Language Understanding...
Team Foundation Server...
ADO.NET DataSet
Scripting
Microsoft Translator U...
ISV Open Discussions
SyncFx - Microsoft Syn...
SQL Server Reporting S...
SQL Server Security
SQL Server Data Wareho...
SQL Server Spatial
SQL Server Migration
SQL Server PowerPivot ...
SQL Server Data Qualit...
Standard 2009: Embedde...
Standard 7: Tools
Windows Embedded Compa...
SQL Server 2012 High A...
SQL Server 2012 Report...
Windows Live  Spaces: ...
Dynamics 365 for Custo...
MSDN Subscriptions Fee...
Known Issues for Windo...
Bing Maps General
Bing Maps REST, SOAP, ...
Office XML, ODF, and B...
Microsoft Lync Client ...
Silverlight Installati...
Report a Silverlight Bug
MVVM / ViewModel Patte...
PivotViewer Control wi...
Designing with Silverl...
Expression Blend + Ske...
Expression Web and Sup...
Microsoft Online Syndi...
Retired SharePoint Exc...
.NET Remoting and Runt...
Building Windows Store...
Core Coding Experience...
Game Technologies: Dir...
Game Technologies: XNA...
Git, Mercurial and Dro...
Innovate on Office
ISV Community Days
Microsoft ESP Platform...
Model-Based Testing wi...
Moderator Posting Only...
Pex and Moles PowerTool
Phoenix
Server Core Developers
Silverlight (formerly ...
Silverlight (formerly ...
Service Bus EAI & EDI ...
Tailoring your Windows...
Visual Basic 2008 (Pre...
Visual Basic Express E...
Visual Basic IDE
Visual Studio 2008 Exp...
Web Sandbox - Exploits
Mango Update (Archived)
XML Paper Specificatio...
XNA Framework
Kinect for Windows v1 SDK

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile