1 //------------------------------------------------------------------------------
2 // <copyright file="HandlerBase.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">Microsoft</owner>
6 // <owner current="true" primary="false">Microsoft</owner>
7 //------------------------------------------------------------------------------
9 namespace System.Data.Common {
12 using System.Collections;
13 using System.Configuration;
14 using System.Diagnostics;
15 using System.Globalization;
18 internal static class HandlerBase {
20 static internal void CheckForChildNodes(XmlNode node) {
21 if (node.HasChildNodes) {
22 throw ADP.ConfigBaseNoChildNodes(node.FirstChild);
25 static private void CheckForNonElement(XmlNode node) {
26 if (XmlNodeType.Element != node.NodeType) {
27 throw ADP.ConfigBaseElementsOnly(node);
30 static internal void CheckForUnrecognizedAttributes(XmlNode node) {
31 if (0 != node.Attributes.Count) {
32 throw ADP.ConfigUnrecognizedAttributes(node);
36 // skip whitespace and comments, throws if non-element
37 static internal bool IsIgnorableAlsoCheckForNonElement(XmlNode node) {
38 if ((XmlNodeType.Comment == node.NodeType) || (XmlNodeType.Whitespace == node.NodeType)) {
41 CheckForNonElement(node);
45 static internal string RemoveAttribute(XmlNode node, string name, bool required, bool allowEmpty) {
46 XmlNode attribute = node.Attributes.RemoveNamedItem(name);
47 if (null == attribute) {
49 throw ADP.ConfigRequiredAttributeMissing(name, node);
53 string value = attribute.Value;
54 if (!allowEmpty && (0 == value.Length)) {
55 throw ADP.ConfigRequiredAttributeEmpty(name, node);
60 static internal DataSet CloneParent(DataSet parentConfig, bool insenstive) {
61 if (null == parentConfig) {
62 parentConfig = new DataSet(DbProviderFactoriesConfigurationHandler.sectionName);
63 parentConfig.CaseSensitive = !insenstive;
64 parentConfig.Locale = CultureInfo.InvariantCulture;
67 parentConfig = parentConfig.Copy();