Imported Upstream version 4.6.0.125

Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-08-03 10:59:49 +00:00
parent a569aebcfd
commit e79aa3c0ed
17047 changed files with 3137615 additions and 392334 deletions

View File

@@ -0,0 +1,39 @@
//------------------------------------------------------------------------------
// <copyright file="ConfigXmlAttribute.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration
{
using System.Configuration.Internal;
using System.IO;
using System.Xml;
using System.Security.Permissions;
internal sealed class ConfigXmlAttribute : XmlAttribute, IConfigErrorInfo {
int _line;
string _filename;
public ConfigXmlAttribute( string filename, int line, string prefix, string localName, string namespaceUri, XmlDocument doc )
: base( prefix, localName, namespaceUri, doc ) {
_line = line;
_filename = filename;
}
int IConfigErrorInfo.LineNumber {
get { return _line; }
}
string IConfigErrorInfo.Filename {
get { return _filename; }
}
public override XmlNode CloneNode(bool deep) {
XmlNode cloneNode = base.CloneNode(deep);
ConfigXmlAttribute clone = cloneNode as ConfigXmlAttribute;
if (clone != null) {
clone._line = _line;
clone._filename = _filename;
}
return cloneNode;
}
}
}

View File

@@ -0,0 +1,39 @@
//------------------------------------------------------------------------------
// <copyright file="ConfigXmlCDataSection.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration
{
using System.Configuration.Internal;
using System.IO;
using System.Xml;
using System.Security.Permissions;
internal sealed class ConfigXmlCDataSection : XmlCDataSection, IConfigErrorInfo {
int _line;
string _filename;
public ConfigXmlCDataSection( string filename, int line, string data, XmlDocument doc )
: base( data, doc) {
_line = line;
_filename = filename;
}
int IConfigErrorInfo.LineNumber {
get { return _line; }
}
string IConfigErrorInfo.Filename {
get { return _filename; }
}
public override XmlNode CloneNode(bool deep) {
XmlNode cloneNode = base.CloneNode(deep);
ConfigXmlCDataSection clone = cloneNode as ConfigXmlCDataSection;
if (clone != null) {
clone._line = _line;
clone._filename = _filename;
}
return cloneNode;
}
}
}

View File

@@ -0,0 +1,39 @@
//------------------------------------------------------------------------------
// <copyright file="ConfigXmlComment.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration
{
using System.Configuration.Internal;
using System.IO;
using System.Xml;
using System.Security.Permissions;
internal sealed class ConfigXmlComment : XmlComment, IConfigErrorInfo {
int _line;
string _filename;
public ConfigXmlComment( string filename, int line, string comment, XmlDocument doc )
: base( comment, doc ) {
_line = line;
_filename = filename;
}
int IConfigErrorInfo.LineNumber {
get { return _line; }
}
string IConfigErrorInfo.Filename {
get { return _filename; }
}
public override XmlNode CloneNode(bool deep) {
XmlNode cloneNode = base.CloneNode(deep);
ConfigXmlComment clone = cloneNode as ConfigXmlComment;
if (clone != null) {
clone._line = _line;
clone._filename = _filename;
}
return cloneNode;
}
}
}

View File

@@ -0,0 +1,118 @@
//------------------------------------------------------------------------------
// <copyright file="ConfigXmlDocument.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration
{
using System.Configuration.Internal;
using System.IO;
using System.Xml;
using System.Security.Permissions;
// ConfigXmlDocument - the default Xml Document doesn't track line numbers, and line
// numbers are necessary to display source on config errors.
// These classes wrap corresponding System.Xml types and also carry
// the necessary information for reporting filename / line numbers.
// Note: these classes will go away if webdata ever decides to incorporate line numbers
// into the default XML classes. This class could also go away if webdata brings back
// the UserData property to hang any info off of any node.
[PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")]
public sealed class ConfigXmlDocument : XmlDocument, IConfigErrorInfo {
XmlTextReader _reader;
int _lineOffset;
string _filename;
int IConfigErrorInfo.LineNumber {
get {
if (_reader == null) {
return 0;
}
if (_lineOffset > 0) {
return _reader.LineNumber + _lineOffset - 1;
}
return _reader.LineNumber;
}
}
public int LineNumber { get { return ((IConfigErrorInfo)this).LineNumber; } }
public string Filename {
get { return ConfigurationException.SafeFilename(_filename); }
}
string IConfigErrorInfo.Filename {
get { return _filename; }
}
public override void Load(string filename) {
_filename = filename;
try {
_reader = new XmlTextReader(filename);
_reader.XmlResolver = null;
base.Load(_reader);
}
finally {
if (_reader != null) {
_reader.Close();
_reader = null;
}
}
}
#if UNUSED_CODE
internal XmlNode ReadConfigNode(string filename, XmlTextReader sourceReader) {
_filename = filename;
_reader = sourceReader; // pull line numbers from original reader
try {
return base.ReadNode(sourceReader);
}
finally {
_reader = null;
}
}
#endif
public void LoadSingleElement(string filename, XmlTextReader sourceReader) {
_filename = filename;
_lineOffset = sourceReader.LineNumber;
string outerXml = sourceReader.ReadOuterXml();
try {
_reader = new XmlTextReader(new StringReader(outerXml), sourceReader.NameTable);
base.Load(_reader);
}
finally {
if (_reader != null) {
_reader.Close();
_reader = null;
}
}
}
public override XmlAttribute CreateAttribute( string prefix, string localName, string namespaceUri ) {
return new ConfigXmlAttribute( _filename, LineNumber, prefix, localName, namespaceUri, this );
}
public override XmlElement CreateElement( string prefix, string localName, string namespaceUri) {
return new ConfigXmlElement( _filename, LineNumber, prefix, localName, namespaceUri, this );
}
public override XmlText CreateTextNode(String text) {
return new ConfigXmlText( _filename, LineNumber, text, this );
}
public override XmlCDataSection CreateCDataSection(String data) {
return new ConfigXmlCDataSection( _filename, LineNumber, data, this );
}
public override XmlComment CreateComment(String data) {
return new ConfigXmlComment( _filename, LineNumber, data, this );
}
public override XmlSignificantWhitespace CreateSignificantWhitespace(String data) {
return new ConfigXmlSignificantWhitespace( _filename, LineNumber, data, this );
}
public override XmlWhitespace CreateWhitespace(String data) {
return new ConfigXmlWhitespace( _filename, LineNumber, data, this );
}
}
}

View File

@@ -0,0 +1,39 @@
//------------------------------------------------------------------------------
// <copyright file="ConfigXmlElement.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration
{
using System.Configuration.Internal;
using System.IO;
using System.Xml;
using System.Security.Permissions;
internal sealed class ConfigXmlElement : XmlElement, IConfigErrorInfo {
int _line;
string _filename;
public ConfigXmlElement( string filename, int line, string prefix, string localName, string namespaceUri, XmlDocument doc )
: base( prefix, localName, namespaceUri, doc) {
_line = line;
_filename = filename;
}
int IConfigErrorInfo.LineNumber {
get { return _line; }
}
string IConfigErrorInfo.Filename {
get { return _filename; }
}
public override XmlNode CloneNode(bool deep) {
XmlNode cloneNode = base.CloneNode(deep);
ConfigXmlElement clone = cloneNode as ConfigXmlElement;
if (clone != null) {
clone._line = _line;
clone._filename = _filename;
}
return cloneNode;
}
}
}

View File

@@ -0,0 +1,39 @@
//------------------------------------------------------------------------------
// <copyright file="ConfigXmlSignificantWhitespace.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration
{
using System.Configuration.Internal;
using System.IO;
using System.Xml;
using System.Security.Permissions;
internal sealed class ConfigXmlSignificantWhitespace : XmlSignificantWhitespace, IConfigErrorInfo {
public ConfigXmlSignificantWhitespace(string filename, int line, string strData, XmlDocument doc)
: base(strData, doc) {
_line = line;
_filename = filename;
}
int _line;
string _filename;
int IConfigErrorInfo.LineNumber {
get { return _line; }
}
string IConfigErrorInfo.Filename {
get { return _filename; }
}
public override XmlNode CloneNode(bool deep) {
XmlNode cloneNode = base.CloneNode(deep);
ConfigXmlSignificantWhitespace clone = cloneNode as ConfigXmlSignificantWhitespace;
if (clone != null) {
clone._line = _line;
clone._filename = _filename;
}
return cloneNode;
}
}
}

View File

@@ -0,0 +1,39 @@
//------------------------------------------------------------------------------
// <copyright file="ConfigXmlText.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration
{
using System.Configuration.Internal;
using System.IO;
using System.Xml;
using System.Security.Permissions;
internal sealed class ConfigXmlText : XmlText, IConfigErrorInfo {
int _line;
string _filename;
public ConfigXmlText( string filename, int line, string strData, XmlDocument doc )
: base( strData, doc ) {
_line = line;
_filename = filename;
}
int IConfigErrorInfo.LineNumber {
get { return _line; }
}
string IConfigErrorInfo.Filename {
get { return _filename; }
}
public override XmlNode CloneNode(bool deep) {
XmlNode cloneNode = base.CloneNode(deep);
ConfigXmlText clone = cloneNode as ConfigXmlText;
if (clone != null) {
clone._line = _line;
clone._filename = _filename;
}
return cloneNode;
}
}
}

View File

@@ -0,0 +1,39 @@
//------------------------------------------------------------------------------
// <copyright file="ConfigXmlWhitespace.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration
{
using System.Configuration.Internal;
using System.IO;
using System.Xml;
using System.Security.Permissions;
internal sealed class ConfigXmlWhitespace : XmlWhitespace, IConfigErrorInfo {
public ConfigXmlWhitespace( string filename, int line, string comment, XmlDocument doc )
: base( comment, doc ) {
_line = line;
_filename = filename;
}
int _line;
string _filename;
int IConfigErrorInfo.LineNumber {
get { return _line; }
}
string IConfigErrorInfo.Filename {
get { return _filename; }
}
public override XmlNode CloneNode(bool deep) {
XmlNode cloneNode = base.CloneNode(deep);
ConfigXmlWhitespace clone = cloneNode as ConfigXmlWhitespace;
if (clone != null) {
clone._line = _line;
clone._filename = _filename;
}
return cloneNode;
}
}
}

View File

@@ -0,0 +1,225 @@
//------------------------------------------------------------------------------
// <copyright file="ConfigurationException.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration {
using System.Configuration.Internal;
using System.Globalization;
using System.IO;
using System.Runtime.Serialization;
using System.Security;
using System.Security.Permissions;
using System.Xml;
using System.Collections;
using System.Runtime.Versioning;
// A config exception can contain a filename (of a config file)
// and a line number (of the location in the file in which a problem was
// encountered).
//
// Section handlers should throw this exception (or subclasses)
// together with filename and line nubmer information where possible.
[Serializable]
public class ConfigurationException : SystemException {
private const string HTTP_PREFIX = "http:";
private string _filename;
private int _line;
void Init(string filename, int line) {
HResult = HResults.Configuration;
_filename = filename;
_line = line;
}
// Default ctor is required for serialization.
protected ConfigurationException(SerializationInfo info, StreamingContext context) : base(info, context) {
Init(info.GetString("filename"), info.GetInt32("line"));
}
[Obsolete("This class is obsolete, to create a new exception create a System." +
"Configuration!System.Configuration.ConfigurationErrorsException")]
public ConfigurationException() :
this(null, null, null, 0) {}
[Obsolete("This class is obsolete, to create a new exception create a System." +
"Configuration!System.Configuration.ConfigurationErrorsException")]
public ConfigurationException(string message) :
this(message, null, null, 0) {}
[Obsolete("This class is obsolete, to create a new exception create a System." +
"Configuration!System.Configuration.ConfigurationErrorsException")]
public ConfigurationException(string message, Exception inner) :
this(message, inner, null, 0) {}
[Obsolete("This class is obsolete, to create a new exception create a System." +
"Configuration!System.Configuration.ConfigurationErrorsException")]
public ConfigurationException(string message, XmlNode node) :
this(message, null, GetUnsafeXmlNodeFilename(node), GetXmlNodeLineNumber(node)) {}
[Obsolete("This class is obsolete, to create a new exception create a System." +
"Configuration!System.Configuration.ConfigurationErrorsException")]
public ConfigurationException(string message, Exception inner, XmlNode node) :
this(message, inner, GetUnsafeXmlNodeFilename(node), GetXmlNodeLineNumber(node)) {}
[Obsolete("This class is obsolete, to create a new exception create a System." +
"Configuration!System.Configuration.ConfigurationErrorsException")]
public ConfigurationException(string message, string filename, int line) :
this(message, null, filename, line) {}
[Obsolete("This class is obsolete, to create a new exception create a System." +
"Configuration!System.Configuration.ConfigurationErrorsException")]
public ConfigurationException(string message, Exception inner, string filename, int line) : base(message, inner) {
Init(filename, line);
}
[SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter=true)]
public override void GetObjectData(SerializationInfo info, StreamingContext context) {
base.GetObjectData(info, context);
info.AddValue("filename", _filename);
info.AddValue("line", _line);
}
// The message includes the file/line number information.
// To get the message without the extra information, use BareMessage.
public override string Message {
get {
string file = Filename;
if (!string.IsNullOrEmpty(file)) {
if (Line != 0) {
return BareMessage + " (" + file + " line " + Line.ToString(CultureInfo.InvariantCulture) + ")";
}
else {
return BareMessage + " (" + file + ")";
}
}
else if (Line != 0) {
return BareMessage + " (line " + Line.ToString("G", CultureInfo.InvariantCulture) + ")";
}
else {
return BareMessage;
}
}
}
public virtual string BareMessage {
get {
return base.Message;
}
}
public virtual string Filename {
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
get {
return SafeFilename(_filename);
}
}
public virtual int Line {
get {
return _line;
}
}
[Obsolete("This class is obsolete, use System.Configuration!System.Configuration." +
"ConfigurationErrorsException.GetFilename instead")]
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
public static string GetXmlNodeFilename(XmlNode node) {
return SafeFilename(GetUnsafeXmlNodeFilename(node));
}
[Obsolete("This class is obsolete, use System.Configuration!System.Configuration." +
"ConfigurationErrorsException.GetLinenumber instead")]
public static int GetXmlNodeLineNumber(XmlNode node) {
IConfigErrorInfo configNode = node as IConfigErrorInfo;
if (configNode != null) {
return configNode.LineNumber;
}
return 0;
}
[FileIOPermission(SecurityAction.Assert, AllFiles=FileIOPermissionAccess.PathDiscovery)]
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
private static string FullPathWithAssert(string filename) {
string fullPath = null;
try {
fullPath = Path.GetFullPath(filename);
}
catch {
}
return fullPath;
}
//
// Internal Helper to strip a full path to just filename.ext when caller
// does not have path discovery to the path (used for sane error handling).
//
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
internal static string SafeFilename(string filename) {
if (string.IsNullOrEmpty(filename)) {
return filename;
}
// configuration file can be an http URL in IE
if (filename.StartsWith(HTTP_PREFIX, StringComparison.OrdinalIgnoreCase)) {
return filename;
}
//
// If it is a relative path, return it as is.
// This could happen if the exception was constructed from the serialization constructor,
// and the caller did not have PathDiscoveryPermission for the file.
//
try {
if (!Path.IsPathRooted(filename)) {
return filename;
}
}
catch {
return null;
}
try {
// Confirm that it is a full path.
// GetFullPath will also Demand PathDiscovery for the resulting path
string fullPath = Path.GetFullPath(filename);
}
catch (SecurityException) {
// Get just the name of the file without the directory part.
try {
string fullPath = FullPathWithAssert(filename);
filename = Path.GetFileName(fullPath);
}
catch {
filename = null;
}
}
catch {
filename = null;
}
return filename;
}
private static string GetUnsafeXmlNodeFilename(XmlNode node) {
IConfigErrorInfo configNode = node as IConfigErrorInfo;
if (configNode != null) {
return configNode.Filename;
}
return string.Empty;
}
}
}

View File

@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <copyright file="ConfigurationManagerInternalFactory.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration {
using System.Configuration.Internal;
//
// class ConfigurationManagerInternalFactory manages access to a
// single instance of ConfigurationManagerInternal.
//
internal static class ConfigurationManagerInternalFactory {
private const string ConfigurationManagerInternalTypeString = "System.Configuration.Internal.ConfigurationManagerInternal, " + AssemblyRef.SystemConfiguration;
static private volatile IConfigurationManagerInternal s_instance;
static internal IConfigurationManagerInternal Instance {
get {
if (s_instance == null) {
s_instance = (IConfigurationManagerInternal) TypeUtil.CreateInstanceWithReflectionPermission(ConfigurationManagerInternalTypeString);
}
return s_instance;
}
}
}
}

View File

@@ -0,0 +1,28 @@
//------------------------------------------------------------------------------
// <copyright file="ConfigurationSettings.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration {
using System.Collections.Specialized;
public sealed class ConfigurationSettings {
private ConfigurationSettings() {}
[Obsolete("This method is obsolete, it has been replaced by System.Configuration!System." +
"Configuration.ConfigurationManager.AppSettings")]
public static NameValueCollection AppSettings {
get {
return ConfigurationManager.AppSettings;
}
}
[Obsolete("This method is obsolete, it has been replaced by System.Configuration!System." +
"Configuration.ConfigurationManager.GetSection")]
public static object GetConfig(string sectionName) {
return ConfigurationManager.GetSection( sectionName );
}
}
}

View File

@@ -0,0 +1,104 @@
//------------------------------------------------------------------------------
// <copyright file="DictionarySectionHandler.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration {
using System.Collections;
using System.Collections.Specialized;
using System.Xml;
using System.Globalization;
/// <devdoc>
/// Simple dictionary config factory
/// config is a dictionary mapping key-&gt;value
///
/// &lt;add key="name" value="text"&gt; sets key=text
/// &lt;remove key="name"&gt; removes the definition of key
/// &lt;clear&gt; removes all definitions
///
/// </devdoc>
public class DictionarySectionHandler : IConfigurationSectionHandler {
/// <devdoc>
/// Given a partially composed config object (possibly null)
/// and some input from the config system, return a
/// further partially composed config object
/// </devdoc>
public virtual object Create(Object parent, Object context, XmlNode section) {
Hashtable res;
// start res off as a shallow clone of the parent
if (parent == null)
res = new Hashtable(StringComparer.OrdinalIgnoreCase);
else
res = (Hashtable)((Hashtable)parent).Clone();
// process XML
HandlerBase.CheckForUnrecognizedAttributes(section);
foreach (XmlNode child in section.ChildNodes) {
// skip whitespace and comments, throws if non-element
if (HandlerBase.IsIgnorableAlsoCheckForNonElement(child))
continue;
// handle <add>, <remove>, <clear> tags
if (child.Name == "add") {
HandlerBase.CheckForChildNodes(child);
String key = HandlerBase.RemoveRequiredAttribute(child, KeyAttributeName);
String value;
if (ValueRequired)
value = HandlerBase.RemoveRequiredAttribute(child, ValueAttributeName);
else
value = HandlerBase.RemoveAttribute(child, ValueAttributeName);
HandlerBase.CheckForUnrecognizedAttributes(child);
if (value == null)
value = "";
res[key] = value;
}
else if (child.Name == "remove") {
HandlerBase.CheckForChildNodes(child);
String key = HandlerBase.RemoveRequiredAttribute(child, KeyAttributeName);
HandlerBase.CheckForUnrecognizedAttributes(child);
res.Remove(key);
}
else if (child.Name.Equals("clear")) {
HandlerBase.CheckForChildNodes(child);
HandlerBase.CheckForUnrecognizedAttributes(child);
res.Clear();
}
else {
HandlerBase.ThrowUnrecognizedElement(child);
}
}
return res;
}
/// <devdoc>
/// Make the name of the key attribute configurable by derived classes.
/// </devdoc>
protected virtual string KeyAttributeName {
get { return "key";}
}
/// <devdoc>
/// Make the name of the value attribute configurable by derived classes.
/// </devdoc>
protected virtual string ValueAttributeName {
get { return "value";}
}
//
internal virtual bool ValueRequired {
get { return false; }
}
}
}

View File

@@ -0,0 +1,264 @@
//------------------------------------------------------------------------------
// <copyright file="HandlerBase.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration {
using System.Globalization;
using System.Xml;
internal class HandlerBase {
private HandlerBase() {
}
//
// XML Attribute Helpers
//
private static XmlNode GetAndRemoveAttribute(XmlNode node, string attrib, bool fRequired) {
XmlNode a = node.Attributes.RemoveNamedItem(attrib);
// If the attribute is required and was not present, throw
if (fRequired && a == null) {
throw new ConfigurationErrorsException(
SR.GetString(SR.Config_missing_required_attribute, attrib, node.Name),
node);
}
return a;
}
private static XmlNode GetAndRemoveStringAttributeInternal(XmlNode node, string attrib, bool fRequired, ref string val) {
XmlNode a = GetAndRemoveAttribute(node, attrib, fRequired);
if (a != null)
val = a.Value;
return a;
}
internal static XmlNode GetAndRemoveStringAttribute(XmlNode node, string attrib, ref string val) {
return GetAndRemoveStringAttributeInternal(node, attrib, false /*fRequired*/, ref val);
}
#if UNUSED_CODE
internal static XmlNode GetAndRemoveRequiredStringAttribute(XmlNode node, string attrib, ref string val) {
return GetAndRemoveStringAttributeInternal(node, attrib, true /*fRequired*/, ref val);
}
#endif
// input.Xml cursor must be at a true/false XML attribute
private static XmlNode GetAndRemoveBooleanAttributeInternal(XmlNode node, string attrib, bool fRequired, ref bool val) {
XmlNode a = GetAndRemoveAttribute(node, attrib, fRequired);
if (a != null) {
try {
val = bool.Parse(a.Value);
}
catch (Exception e) {
throw new ConfigurationErrorsException(
SR.GetString(SR.GetString(SR.Config_invalid_boolean_attribute, a.Name)),
e, a);
}
}
return a;
}
internal static XmlNode GetAndRemoveBooleanAttribute(XmlNode node, string attrib, ref bool val) {
return GetAndRemoveBooleanAttributeInternal(node, attrib, false /*fRequired*/, ref val);
}
#if UNUSED_CODE
internal static XmlNode GetAndRemoveRequiredBooleanAttribute(XmlNode node, string attrib, ref bool val) {
return GetAndRemoveBooleanAttributeInternal(node, attrib, true /*fRequired*/, ref val);
}
#endif
// input.Xml cursor must be an integer XML attribute
private static XmlNode GetAndRemoveIntegerAttributeInternal(XmlNode node, string attrib, bool fRequired, ref int val) {
XmlNode a = GetAndRemoveAttribute(node, attrib, fRequired);
if (a != null) {
if (a.Value.Trim() != a.Value) {
throw new ConfigurationErrorsException(
SR.GetString(SR.Config_invalid_integer_attribute, a.Name), a);
}
try {
val = int.Parse(a.Value, CultureInfo.InvariantCulture);
}
catch (Exception e) {
throw new ConfigurationErrorsException(
SR.GetString(SR.Config_invalid_integer_attribute, a.Name),
e, a);
}
}
return a;
}
internal static XmlNode GetAndRemoveIntegerAttribute(XmlNode node, string attrib, ref int val) {
return GetAndRemoveIntegerAttributeInternal(node, attrib, false /*fRequired*/, ref val);
}
#if UNUSED_CODE
internal static XmlNode GetAndRemoveRequiredIntegerAttribute(XmlNode node, string attrib, ref int val) {
return GetAndRemoveIntegerAttributeInternal(node, attrib, true /*fRequired*/, ref val);
}
#endif
#if UNUSED_CODE
private static XmlNode GetAndRemovePositiveIntegerAttributeInternal(XmlNode node, string attrib, bool fRequired, ref int val) {
XmlNode a = GetAndRemoveIntegerAttributeInternal(node, attrib, fRequired, ref val);
if (a != null && val < 0) {
throw new ConfigurationErrorsException(
SR.GetString(SR.Config_invalid_positive_integer_attribute, attrib),
node);
}
return a;
}
#endif
#if UNUSED_CODE
internal static XmlNode GetAndRemovePositiveIntegerAttribute(XmlNode node, string attrib, ref int val) {
return GetAndRemovePositiveIntegerAttributeInternal(node, attrib, false /*fRequired*/, ref val);
}
#endif
#if UNUSED_CODE
internal static XmlNode GetAndRemoveRequiredPositiveIntegerAttribute(XmlNode node, string attrib, ref int val) {
return GetAndRemovePositiveIntegerAttributeInternal(node, attrib, true /*fRequired*/, ref val);
}
#endif
#if UNUSED_CODE
private static XmlNode GetAndRemoveTypeAttributeInternal(XmlNode node, string attrib, bool fRequired, ref Type val) {
XmlNode a = GetAndRemoveAttribute(node, attrib, fRequired);
if (a != null) {
try {
val = Type.GetType(a.Value, true /*throwOnError*/);
}
catch (Exception e) {
throw new ConfigurationErrorsException(
e.Message, //SR.GetString(SR.Config_invalid_type_attribute, a.Name),
e, a);
}
}
return a;
}
#endif
#if UNUSED_CODE
internal static XmlNode GetAndRemoveTypeAttribute(XmlNode node, string attrib, ref Type val) {
return GetAndRemoveTypeAttributeInternal(node, attrib, false /*fRequired*/, ref val);
}
#endif
#if UNUSED_CODE
internal static XmlNode GetAndRemoveRequiredTypeAttribute(XmlNode node, string attrib, ref Type val) {
return GetAndRemoveTypeAttributeInternal(node, attrib, true /*fRequired*/, ref val);
}
#endif
internal static void CheckForUnrecognizedAttributes(XmlNode node) {
if (node.Attributes.Count != 0) {
throw new ConfigurationErrorsException(
SR.GetString(SR.Config_base_unrecognized_attribute, node.Attributes[0].Name),
node);
}
}
//
// Obsolete XML Attribute Helpers
//
// if attribute not found return null
internal static string RemoveAttribute(XmlNode node, string name) {
XmlNode attribute = node.Attributes.RemoveNamedItem(name);
if (attribute != null) {
return attribute.Value;
}
return null;
}
// if attr not found throw standard message - "attribute x required"
internal static string RemoveRequiredAttribute(XmlNode node, string name) {
return RemoveRequiredAttribute(node, name, false/*allowEmpty*/);
}
internal static string RemoveRequiredAttribute(XmlNode node, string name, bool allowEmpty) {
XmlNode attribute = node.Attributes.RemoveNamedItem(name);
if (attribute == null) {
throw new ConfigurationErrorsException(
SR.GetString(SR.Config_base_required_attribute_missing, name),
node);
}
if (String.IsNullOrEmpty(attribute.Value) && allowEmpty == false) {
throw new ConfigurationErrorsException(
SR.GetString(SR.Config_base_required_attribute_empty, name),
node);
}
return attribute.Value;
}
//
// XML Element Helpers
//
internal static void CheckForNonElement(XmlNode node) {
if (node.NodeType != XmlNodeType.Element) {
throw new ConfigurationErrorsException(
SR.GetString(SR.Config_base_elements_only),
node);
}
}
internal static bool IsIgnorableAlsoCheckForNonElement(XmlNode node) {
if (node.NodeType == XmlNodeType.Comment || node.NodeType == XmlNodeType.Whitespace) {
return true;
}
CheckForNonElement(node);
return false;
}
internal static void CheckForChildNodes(XmlNode node) {
if (node.HasChildNodes) {
throw new ConfigurationErrorsException(
SR.GetString(SR.Config_base_no_child_nodes),
node.FirstChild);
}
}
internal static void ThrowUnrecognizedElement(XmlNode node) {
throw new ConfigurationErrorsException(
SR.GetString(SR.Config_base_unrecognized_element),
node);
}
//
// Parse Helpers
//
//
}
}

View File

@@ -0,0 +1,36 @@
//------------------------------------------------------------------------------
// <copyright file="IApplicationSettingsProvider.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration {
using System.Security.Permissions;
/// <devdoc>
/// This interface is an extension to SettingsProvider that a provider can implement
/// to support additional functionality for settings classes that derive from ApplicationSettingsBase.
/// </devdoc>
public interface IApplicationSettingsProvider {
/// <devdoc>
/// Retrieves the previous value of a given SettingsProperty. This is used in conjunction with Upgrade.
/// </devdoc>
[PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")]
SettingsPropertyValue GetPreviousVersion(SettingsContext context, SettingsProperty property);
/// <devdoc>
/// Resets all settings to their "default" values.
/// </devdoc>
[PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")]
void Reset(SettingsContext context);
/// <devdoc>
/// Indicates to the provider that the app has been upgraded. This is a chance for the provider to upgrade
/// its stored settings as appropriate.
/// </devdoc>
[PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")]
void Upgrade(SettingsContext context, SettingsPropertyCollection properties);
}
}

View File

@@ -0,0 +1,48 @@
//------------------------------------------------------------------------------
// <copyright file="IConfigurationSectionHandler.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration {
// The IConfigSectionHandler interface defines the contract that all configuration
// section handlers must implement in order to participate in the resolution of
// configuration settings.
//
// Composes and creates config objects.
//
// This interface is implemented by config providers.
// Classes implementing IConfigSectionHandler define the rules for cooking
// XML config into usable objects. The cooked objects
// can be of arbitrary type.
//
// Configuration is composable (e.g., config in a child
// directory is layered over config in a parent directory),
// so, IConfigSectionHandler is supplied with the parent config
// as well as any number of XML fragments.
public interface IConfigurationSectionHandler {
// Create
//
// @param parent the object inherited from parent path
// @param context reserved, in ASP.NET used to convey virtual path of config being evaluated
// @param section the xml node rooted at the section to handle
// @returns a new config object
//
// The function is responsible for inspecting "section", "context",
// and "parent", and creating a config object.
//
// Note that "parent" is guaranteed to be an object that
// was returned from a Create call on the same IConfigSectionHandler
// implementation. (E.g., if Create returns a Hashtable,
// then "parent" is always a Hashtable if it's non-null.)
//
// Returned objects must be immutable. In particular,
// it's important that the "parent" object being passed
// in is not altered: if a modification must be made,
// then it must be cloned before it is modified.
object Create(Object parent, Object configContext, System.Xml.XmlNode section);
}
}

View File

@@ -0,0 +1,18 @@
//------------------------------------------------------------------------------
// <copyright file="IConfigurationSystem.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration {
// obsolete
[System.Runtime.InteropServices.ComVisible(false)]
public interface IConfigurationSystem {
// Returns the config object for the specified key.
object GetConfig(string configKey);
// Initializes the configuration system.
void Init();
}
}

View File

@@ -0,0 +1,43 @@
//------------------------------------------------------------------------------
// <copyright file="IPersistComponentSettings.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration {
/// <devdoc>
/// Components should implement this interface if they want to persist custom settings
/// in a hosting application. This interface allows the application author to tell a control
/// whether to persist, when to load, save etc.
/// </devdoc>
public interface IPersistComponentSettings {
/// <devdoc>
/// Indicates to the implementor that settings should be persisted.
/// </devdoc>
bool SaveSettings { get; set; }
/// <devdoc>
/// Unique key that identifies an individual instance of a settings group(s). This key is needed
/// to identify which instance of a component owns a given group(s) of settings. Usually, the component
/// will frame its own key, but this property allows the hosting application to override it if necessary.
/// </devdoc>
string SettingsKey { get; set; }
/// <devdoc>
/// Tells the component to load its settings.
/// </devdoc>
void LoadComponentSettings();
/// <devdoc>
/// Tells the component to save its settings.
/// </devdoc>
void SaveComponentSettings();
/// <devdoc>
/// Tells the component to reset its settings. Typically, the component can call Reset on its settings class(es).
/// </devdoc>
void ResetComponentSettings();
}
}

View File

@@ -0,0 +1,24 @@
//------------------------------------------------------------------------------
// <copyright file="ISettingsProviderService.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Configuration {
/// <devdoc>
/// The IPersistComponentSettings interface enables components hosted in an application to persist their
/// settings in a manner transparent to the application. However, in some cases, the application may want to
/// override the provider(s) specified by a component. For example, at design time, we may want to persist
/// settings differently. This service enables this scenario. The ApplicationSettingsBase class queries this
/// service from the owner component's site.
/// </devdoc>
public interface ISettingsProviderService {
/// <devdoc>
/// Queries the service whether it wants to override the provider for the given SettingsProperty. If it
/// doesn't want to, it should return null, in which the provider will remain unchanged.
/// </devdoc>
SettingsProvider GetSettingsProvider(SettingsProperty property);
}
}

Some files were not shown because too many files have changed in this diff Show More