mail-archives/mono-list/2003-October/016576.html

128 строки
4.1 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-list] ProviderSectionHandler revisited
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:marco.canini%40fastwebnet.it">
<META NAME="robots" CONTENT="index,nofollow">
<LINK REL="Previous" HREF="016546.html">
<LINK REL="Next" HREF="016638.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-list] ProviderSectionHandler revisited
</H1>
<B>Marco Canini
</B>
<A HREF="mailto:marco.canini%40fastwebnet.it"
TITLE="[Mono-list] ProviderSectionHandler revisited">marco.canini@fastwebnet.it
</A><BR>
<I>Mon, 27 Oct 2003 19:43:26 +0100</I>
<P><UL>
<LI> Previous message: <A HREF="016546.html">[Mono-list] ProviderSectionHandler revisited
</A></li>
<LI> Next message: <A HREF="016638.html">[Mono-list] ProviderSectionHandler revisited
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#16576">[ date ]</a>
<a href="thread.html#16576">[ thread ]</a>
<a href="subject.html#16576">[ subject ]</a>
<a href="author.html#16576">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>This is a multi-part message in MIME format.
--------------010606040901040709090906
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Could someone review this new version of ProviderSectionHandler.cs and
if right commit it please.
I need ProviderFactory to work for my job.
MC
--------------010606040901040709090906
Content-Type: text/plain;
name=&quot;ProviderSectionHandler.cs&quot;
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename=&quot;ProviderSectionHandler.cs&quot;
//
// Mono.Data.ProviderSectionHandler
//
// Authors:
// Brian Ritchie (<A HREF="mailto:brianlritchie@hotmail.com">brianlritchie@hotmail.com</A>)
//
//
// Copyright (C) Brian Ritchie, 2002
//
// Modified by Marco Canini &lt;<A HREF="mailto:marco.canini@fastwebnet.it">marco.canini@fastwebnet.it</A>&gt; on 24 October 2003
// * Use XPath to select all provider node under providers to get sure it doesn't
// throw exception when there're comments and whitespaces in providers node
using System;
using System.Xml;
using System.Configuration;
namespace Mono.Data
{
public class ProviderSectionHandler : IConfigurationSectionHandler
{
public virtual object Create(object parent,object configContext,XmlNode section)
{
ProviderCollection providers = new ProviderCollection ();
XmlNodeList ProviderList = section.SelectNodes (&quot;./provider&quot;);
foreach (XmlNode ProviderNode in ProviderList) {
Provider provider = new Provider (
GetStringValue (ProviderNode,&quot;name&quot;,true),
GetStringValue (ProviderNode,&quot;connection&quot;,true),
GetStringValue (ProviderNode,&quot;adapter&quot;,true),
GetStringValue (ProviderNode,&quot;command&quot;,true),
GetStringValue (ProviderNode,&quot;assembly&quot;,true),
GetStringValue (ProviderNode,&quot;description&quot;,false));
providers.Add (provider);
}
return providers;
}
private string GetStringValue(XmlNode _node, string _attribute, bool required)
{
XmlNode a = _node.Attributes.RemoveNamedItem (_attribute);
if (a == null) {
if (required)
throw new ConfigurationException (&quot;Attribute required: &quot; + _attribute);
else
return null;
}
return a.Value;
}
}
}
--------------010606040901040709090906--
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI> Previous message: <A HREF="016546.html">[Mono-list] ProviderSectionHandler revisited
</A></li>
<LI> Next message: <A HREF="016638.html">[Mono-list] ProviderSectionHandler revisited
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#16576">[ date ]</a>
<a href="thread.html#16576">[ thread ]</a>
<a href="subject.html#16576">[ subject ]</a>
<a href="author.html#16576">[ author ]</a>
</LI>
</UL>
</body></html>