You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 4610231f55806d2a05ed69e5ff3faa7336cc1479
This commit is contained in:
committed by
Jo Shields
parent
aa7da660d6
commit
c042cd0c52
@@ -66,10 +66,12 @@ namespace System.ServiceModel.Diagnostics
|
||||
this.CreateTraceSource();
|
||||
this.AddDomainEventHandlersForCleanup();
|
||||
}
|
||||
#if !NO_CONFIGURATION
|
||||
catch (ConfigurationErrorsException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
catch (Exception e)
|
||||
{
|
||||
if (Fx.IsFatal(e))
|
||||
|
@@ -2,6 +2,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if !NO_CONFIGURATION
|
||||
namespace System.ServiceModel.Configuration
|
||||
{
|
||||
using System.Configuration;
|
||||
@@ -51,5 +52,7 @@ namespace System.ServiceModel.Configuration
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@@ -4,11 +4,15 @@
|
||||
|
||||
namespace System.ServiceModel.Diagnostics
|
||||
{
|
||||
#if !NO_CONFIGURATION
|
||||
using System.Configuration;
|
||||
#endif
|
||||
using System.Diagnostics;
|
||||
using System.Runtime;
|
||||
using System.Runtime.Diagnostics;
|
||||
#if !NO_CONFIGURATION
|
||||
using System.ServiceModel.Configuration;
|
||||
#endif
|
||||
|
||||
class PiiTraceSource : TraceSource
|
||||
{
|
||||
@@ -59,7 +63,11 @@ namespace System.ServiceModel.Diagnostics
|
||||
#pragma warning disable 618
|
||||
System.Runtime.Diagnostics.EventLogger logger = new System.Runtime.Diagnostics.EventLogger(this.eventSourceName, null);
|
||||
#pragma warning restore 618
|
||||
#if !NO_CONFIGURATION
|
||||
if (MachineSettingsSection.EnableLoggingKnownPii)
|
||||
#else
|
||||
if (false)
|
||||
#endif
|
||||
{
|
||||
logger.LogEvent(TraceEventType.Information,
|
||||
(ushort)System.Runtime.Diagnostics.EventLogCategory.MessageLogging,
|
||||
|
@@ -13,4 +13,8 @@ MinLengthAttribute_ValidationError=The field {0} must be a string or array type
|
||||
MinLengthAttribute_InvalidMinLength=MinLengthAttribute must have a Length value that is zero or greater.
|
||||
|
||||
## ExceptionType=ArgumentException
|
||||
ArgumentIsNullOrWhitespace=The argument '{0}' cannot be null, empty or contain only white space.
|
||||
ArgumentIsNullOrWhitespace=The argument '{0}' cannot be null, empty or contain only white space.
|
||||
|
||||
RequiredAttribute_ValidationError=The {0} field is required.
|
||||
|
||||
CompareAttribute_MustMatch='{0}' and '{1}' do not match.
|
||||
|
3
external/referencesource/System.Configuration/GlobalSuppressions.cs
vendored
Normal file
3
external/referencesource/System.Configuration/GlobalSuppressions.cs
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope="member", Target="System.Configuration.SR.GetString(System.String,System.Boolean&):System.String")]
|
36
external/referencesource/System.Configuration/Microsoft/Win32/SafeCryptContextHandle.cs
vendored
Normal file
36
external/referencesource/System.Configuration/Microsoft/Win32/SafeCryptContextHandle.cs
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="UnsafeNativeMethods.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Win32 {
|
||||
using System;
|
||||
using System.Security.Permissions;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using System.Configuration;
|
||||
|
||||
// Safehandle for crypt context handles
|
||||
[System.Security.SuppressUnmanagedCodeSecurityAttribute()]
|
||||
internal sealed class SafeCryptContextHandle : SafeHandleZeroOrMinusOneIsInvalid {
|
||||
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
|
||||
internal SafeCryptContextHandle()
|
||||
: base(true) {
|
||||
}
|
||||
|
||||
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
|
||||
internal SafeCryptContextHandle(IntPtr handle, bool ownsHandle)
|
||||
: base(ownsHandle) {
|
||||
SetHandle(handle);
|
||||
}
|
||||
|
||||
override protected bool ReleaseHandle() {
|
||||
if (handle != IntPtr.Zero) {
|
||||
UnsafeNativeMethods.CryptReleaseContext(this, 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
53
external/referencesource/System.Configuration/Microsoft/Win32/SafeNativeMemoryHandle.cs
vendored
Normal file
53
external/referencesource/System.Configuration/Microsoft/Win32/SafeNativeMemoryHandle.cs
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="UnsafeNativeMethods.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Win32 {
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
using System.Security.Permissions;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using System.Configuration;
|
||||
|
||||
// Safehandle for memory handles
|
||||
[System.Security.SuppressUnmanagedCodeSecurityAttribute()]
|
||||
internal sealed class SafeNativeMemoryHandle : SafeHandleZeroOrMinusOneIsInvalid {
|
||||
private bool _useLocalFree = false;
|
||||
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
|
||||
internal SafeNativeMemoryHandle()
|
||||
: this(false) {
|
||||
}
|
||||
|
||||
internal SafeNativeMemoryHandle(bool useLocalFree)
|
||||
: base(true) {
|
||||
_useLocalFree = useLocalFree;
|
||||
}
|
||||
|
||||
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
|
||||
internal SafeNativeMemoryHandle(IntPtr handle, bool ownsHandle)
|
||||
: base(ownsHandle) {
|
||||
SetHandle(handle);
|
||||
}
|
||||
|
||||
internal void SetDataHandle(IntPtr handle) {
|
||||
SetHandle(handle);
|
||||
}
|
||||
|
||||
override protected bool ReleaseHandle() {
|
||||
if (handle != IntPtr.Zero) {
|
||||
if (_useLocalFree == true)
|
||||
UnsafeNativeMethods.LocalFree(handle);
|
||||
else
|
||||
Marshal.FreeHGlobal(handle);
|
||||
handle = IntPtr.Zero;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
29
external/referencesource/System.Configuration/Microsoft/Win32/SafeNativeMethods.cs
vendored
Normal file
29
external/referencesource/System.Configuration/Microsoft/Win32/SafeNativeMethods.cs
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="SafeNativeMethods.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Win32 {
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
using System.Security.Permissions;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
|
||||
[
|
||||
System.Security.SuppressUnmanagedCodeSecurityAttribute()
|
||||
]
|
||||
internal static class SafeNativeMethods {
|
||||
#if NOPERF
|
||||
[DllImport(ExternDll.Kernel32, SetLastError=true)]
|
||||
internal static extern bool QueryPerformanceCounter(out long value);
|
||||
|
||||
[DllImport(ExternDll.Kernel32, SetLastError=true)]
|
||||
internal static extern bool QueryPerformanceFrequency(out long value);
|
||||
#endif
|
||||
}
|
||||
}
|
66
external/referencesource/System.Configuration/Microsoft/Win32/UnsafeNativeMethods.cs
vendored
Normal file
66
external/referencesource/System.Configuration/Microsoft/Win32/UnsafeNativeMethods.cs
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="UnsafeNativeMethods.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Win32 {
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System;
|
||||
using System.Security.Permissions;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using System.Configuration;
|
||||
|
||||
[
|
||||
System.Security.SuppressUnmanagedCodeSecurityAttribute()
|
||||
]
|
||||
internal static class UnsafeNativeMethods {
|
||||
[DllImport(ExternDll.Kernel32, SetLastError=true, CharSet=CharSet.Auto, BestFitMapping=false)]
|
||||
internal static extern bool GetFileAttributesEx(string name, int fileInfoLevel, out WIN32_FILE_ATTRIBUTE_DATA data);
|
||||
|
||||
internal const int GetFileExInfoStandard = 0;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct WIN32_FILE_ATTRIBUTE_DATA {
|
||||
internal int fileAttributes;
|
||||
internal uint ftCreationTimeLow;
|
||||
internal uint ftCreationTimeHigh;
|
||||
internal uint ftLastAccessTimeLow;
|
||||
internal uint ftLastAccessTimeHigh;
|
||||
internal uint ftLastWriteTimeLow;
|
||||
internal uint ftLastWriteTimeHigh;
|
||||
internal uint fileSizeHigh;
|
||||
internal uint fileSizeLow;
|
||||
}
|
||||
|
||||
[DllImport(ExternDll.Kernel32, CharSet=CharSet.Auto, BestFitMapping=false)]
|
||||
internal static extern int GetModuleFileName(HandleRef hModule, StringBuilder buffer, int length);
|
||||
|
||||
#if !FEATURE_PAL
|
||||
[DllImport(ExternDll.Crypt32, SetLastError=true, CharSet=CharSet.Unicode)]
|
||||
internal extern static bool CryptProtectData(ref DATA_BLOB inputData, string description, ref DATA_BLOB entropy, IntPtr pReserved, ref CRYPTPROTECT_PROMPTSTRUCT promptStruct, UInt32 flags, ref DATA_BLOB outputData);
|
||||
|
||||
[DllImport(ExternDll.Crypt32, SetLastError= true, CharSet=CharSet.Unicode)]
|
||||
internal extern static bool CryptUnprotectData(ref DATA_BLOB inputData, IntPtr description, ref DATA_BLOB entropy, IntPtr pReserved, ref CRYPTPROTECT_PROMPTSTRUCT promptStruct, UInt32 flags, ref DATA_BLOB outputData);
|
||||
|
||||
[DllImport(ExternDll.Advapi32, SetLastError=true, CharSet=CharSet.Unicode)]
|
||||
internal extern static int CryptAcquireContext(out SafeCryptContextHandle phProv, string pszContainer, string pszProvider, uint dwProvType, uint dwFlags);
|
||||
|
||||
[DllImport(ExternDll.Advapi32, SetLastError=true, CharSet=CharSet.Unicode)]
|
||||
internal extern static int CryptReleaseContext(SafeCryptContextHandle hProv, uint dwFlags);
|
||||
|
||||
[DllImport(ExternDll.Kernel32, CharSet=CharSet.Auto)]
|
||||
internal extern static IntPtr LocalFree(IntPtr buf);
|
||||
#endif
|
||||
|
||||
// MoveFile Parameter
|
||||
internal const int MOVEFILE_REPLACE_EXISTING = 0x00000001;
|
||||
|
||||
[DllImport(ExternDll.Kernel32, CharSet=CharSet.Auto, BestFitMapping=false)]
|
||||
internal static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, int dwFlags);
|
||||
}
|
||||
}
|
162
external/referencesource/System.Configuration/System/Configuration/AppSettingsSection.cs
vendored
Normal file
162
external/referencesource/System.Configuration/System/Configuration/AppSettingsSection.cs
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="AppSettingsSection.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Configuration {
|
||||
using System;
|
||||
using System.Xml;
|
||||
using System.Configuration;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
public sealed class AppSettingsSection : ConfigurationSection {
|
||||
private volatile static ConfigurationPropertyCollection s_properties;
|
||||
private volatile static ConfigurationProperty s_propAppSettings;
|
||||
private volatile static ConfigurationProperty s_propFile;
|
||||
|
||||
private KeyValueInternalCollection _KeyValueCollection = null;
|
||||
|
||||
private static ConfigurationPropertyCollection EnsureStaticPropertyBag() {
|
||||
if (s_properties == null) {
|
||||
ConfigurationProperty propAppSettings = new ConfigurationProperty(null, typeof(KeyValueConfigurationCollection), null, ConfigurationPropertyOptions.IsDefaultCollection);
|
||||
ConfigurationProperty propFile = new ConfigurationProperty("file", typeof(string), String.Empty, ConfigurationPropertyOptions.None);
|
||||
|
||||
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
|
||||
properties.Add(propAppSettings);
|
||||
properties.Add(propFile);
|
||||
|
||||
s_propAppSettings = propAppSettings;
|
||||
s_propFile = propFile;
|
||||
s_properties = properties;
|
||||
}
|
||||
|
||||
return s_properties;
|
||||
}
|
||||
|
||||
public AppSettingsSection() {
|
||||
EnsureStaticPropertyBag();
|
||||
}
|
||||
|
||||
protected internal override ConfigurationPropertyCollection Properties {
|
||||
get {
|
||||
return EnsureStaticPropertyBag();
|
||||
}
|
||||
}
|
||||
|
||||
protected internal override object GetRuntimeObject() {
|
||||
SetReadOnly();
|
||||
return this.InternalSettings; // return the read only object
|
||||
}
|
||||
|
||||
internal NameValueCollection InternalSettings {
|
||||
get {
|
||||
if (_KeyValueCollection == null) {
|
||||
_KeyValueCollection = new KeyValueInternalCollection(this);
|
||||
}
|
||||
return (NameValueCollection)_KeyValueCollection;
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty("", IsDefaultCollection = true)]
|
||||
public KeyValueConfigurationCollection Settings {
|
||||
get {
|
||||
return (KeyValueConfigurationCollection)base[s_propAppSettings];
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty("file", DefaultValue = "")]
|
||||
public string File {
|
||||
get {
|
||||
string fileValue = (string)base[s_propFile];
|
||||
if (fileValue == null) {
|
||||
return String.Empty;
|
||||
}
|
||||
return fileValue;
|
||||
}
|
||||
set {
|
||||
base[s_propFile] = value;
|
||||
}
|
||||
}
|
||||
protected internal override void Reset(ConfigurationElement parentSection) {
|
||||
_KeyValueCollection = null;
|
||||
base.Reset(parentSection);
|
||||
if (!String.IsNullOrEmpty((string)base[s_propFile])) { // don't inherit from the parent
|
||||
SetPropertyValue(s_propFile,null,true); // ignore the lock to prevent inheritence
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected internal override bool IsModified() {
|
||||
return base.IsModified();
|
||||
}
|
||||
|
||||
protected internal override string SerializeSection(ConfigurationElement parentElement, string name, ConfigurationSaveMode saveMode) {
|
||||
return base.SerializeSection(parentElement, name, saveMode);
|
||||
}
|
||||
|
||||
protected internal override void DeserializeElement(XmlReader reader, bool serializeCollectionKey) {
|
||||
string ElementName = reader.Name;
|
||||
|
||||
base.DeserializeElement(reader, serializeCollectionKey);
|
||||
if ((File != null) && (File.Length > 0)) {
|
||||
string sourceFileFullPath;
|
||||
string configFileDirectory;
|
||||
string configFile;
|
||||
|
||||
// Determine file location
|
||||
configFile = ElementInformation.Source;
|
||||
|
||||
if (String.IsNullOrEmpty(configFile)) {
|
||||
sourceFileFullPath = File;
|
||||
}
|
||||
else {
|
||||
configFileDirectory = System.IO.Path.GetDirectoryName(configFile);
|
||||
sourceFileFullPath = System.IO.Path.Combine(configFileDirectory, File);
|
||||
}
|
||||
|
||||
if (System.IO.File.Exists(sourceFileFullPath)) {
|
||||
int lineOffset = 0;
|
||||
string rawXml = null;
|
||||
|
||||
using (Stream sourceFileStream = new FileStream(sourceFileFullPath, FileMode.Open, FileAccess.Read, FileShare.Read)) {
|
||||
using (XmlUtil xmlUtil = new XmlUtil(sourceFileStream, sourceFileFullPath, true)) {
|
||||
if (xmlUtil.Reader.Name != ElementName) {
|
||||
throw new ConfigurationErrorsException(
|
||||
SR.GetString(SR.Config_name_value_file_section_file_invalid_root, ElementName),
|
||||
xmlUtil);
|
||||
}
|
||||
|
||||
lineOffset = xmlUtil.Reader.LineNumber;
|
||||
rawXml = xmlUtil.CopySection();
|
||||
|
||||
// Detect if there is any XML left over after the section
|
||||
while (!xmlUtil.Reader.EOF) {
|
||||
XmlNodeType t = xmlUtil.Reader.NodeType;
|
||||
if (t != XmlNodeType.Comment) {
|
||||
throw new ConfigurationErrorsException(SR.GetString(SR.Config_source_file_format), xmlUtil);
|
||||
}
|
||||
|
||||
xmlUtil.Reader.Read();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConfigXmlReader internalReader = new ConfigXmlReader(rawXml, sourceFileFullPath, lineOffset);
|
||||
internalReader.Read();
|
||||
if (internalReader.MoveToNextAttribute()) {
|
||||
throw new ConfigurationErrorsException(SR.GetString(SR.Config_base_unrecognized_attribute, internalReader.Name), (XmlReader)internalReader);
|
||||
}
|
||||
|
||||
internalReader.MoveToElement();
|
||||
|
||||
base.DeserializeElement(internalReader, serializeCollectionKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
c378f1d68b1844752e4d0e3355a78cd210a1c01c
|
32
external/referencesource/System.Configuration/System/Configuration/CRYPTPROTECT_PROMPTSTRUCT.cs
vendored
Normal file
32
external/referencesource/System.Configuration/System/Configuration/CRYPTPROTECT_PROMPTSTRUCT.cs
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="CRYPTPROTECT_PROMPTSTRUCT.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Configuration
|
||||
{
|
||||
using System.Collections.Specialized;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Configuration.Provider;
|
||||
using System.Xml;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Win32;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct CRYPTPROTECT_PROMPTSTRUCT : IDisposable
|
||||
{
|
||||
public int cbSize;
|
||||
public int dwPromptFlags;
|
||||
public IntPtr hwndApp;
|
||||
public string szPrompt;
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
hwndApp = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
49
external/referencesource/System.Configuration/System/Configuration/CallbackValidator.cs
vendored
Normal file
49
external/referencesource/System.Configuration/System/Configuration/CallbackValidator.cs
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="CallbackValidator.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Security.Permissions;
|
||||
using System.Xml;
|
||||
using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
using System.ComponentModel;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace System.Configuration {
|
||||
|
||||
public sealed class CallbackValidator : ConfigurationValidatorBase {
|
||||
Type _type;
|
||||
ValidatorCallback _callback;
|
||||
|
||||
public CallbackValidator(Type type, ValidatorCallback callback) : this(callback) {
|
||||
if (type == null) {
|
||||
throw new ArgumentNullException("type");
|
||||
}
|
||||
_type = type;
|
||||
}
|
||||
|
||||
// Do not check for null type here to handle the callback attribute case
|
||||
internal CallbackValidator(ValidatorCallback callback) {
|
||||
if (callback == null) {
|
||||
throw new ArgumentNullException("callback");
|
||||
}
|
||||
_type = null;
|
||||
_callback = callback;
|
||||
}
|
||||
|
||||
public override bool CanValidate(Type type) {
|
||||
return (type == _type || _type == null);
|
||||
}
|
||||
public override void Validate(object value) {
|
||||
_callback(value);
|
||||
}
|
||||
}
|
||||
}
|
80
external/referencesource/System.Configuration/System/Configuration/CallbackValidatorAttribute.cs
vendored
Normal file
80
external/referencesource/System.Configuration/System/Configuration/CallbackValidatorAttribute.cs
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="CallbackValidatorAttribute.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Configuration.Internal;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Security.Permissions;
|
||||
using System.Xml;
|
||||
using System.Globalization;
|
||||
using System.ComponentModel;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
|
||||
namespace System.Configuration {
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public sealed class CallbackValidatorAttribute : ConfigurationValidatorAttribute {
|
||||
private Type _type = null;
|
||||
private String _callbackMethodName = String.Empty;
|
||||
private ValidatorCallback _callbackMethod;
|
||||
|
||||
public override ConfigurationValidatorBase ValidatorInstance {
|
||||
get {
|
||||
if (_callbackMethod == null) {
|
||||
if (_type == null) {
|
||||
throw new ArgumentNullException("Type");
|
||||
}
|
||||
if (!String.IsNullOrEmpty(_callbackMethodName)) {
|
||||
MethodInfo methodInfo = _type.GetMethod(_callbackMethodName, BindingFlags.Public | BindingFlags.Static);
|
||||
if (methodInfo != null) {
|
||||
ParameterInfo[] parameters = methodInfo.GetParameters();
|
||||
if ((parameters.Length == 1) && (parameters[0].ParameterType == typeof(Object))) {
|
||||
// The security here depends on nobody changing the type or callback method once the declaring type has been
|
||||
// set. This currently isn't an issue since the attribute is instantiated then the declaring type is set without
|
||||
// user code having gotten a chance to run in between. But if the behavior of PropertyInfo.GetAttributes ever
|
||||
// changes such that it returns cached attribute instances rather than new instances every time, this assumption is void.
|
||||
_callbackMethod = (ValidatorCallback)TypeUtil.CreateDelegateRestricted(_declaringType, typeof(ValidatorCallback), methodInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_callbackMethod == null) {
|
||||
throw new System.ArgumentException(SR.GetString(SR.Validator_method_not_found, _callbackMethodName));
|
||||
}
|
||||
|
||||
return new CallbackValidator(_callbackMethod);
|
||||
}
|
||||
}
|
||||
|
||||
public CallbackValidatorAttribute() {
|
||||
}
|
||||
|
||||
public Type Type {
|
||||
get {
|
||||
return _type;
|
||||
}
|
||||
set {
|
||||
_type = value;
|
||||
_callbackMethod = null;
|
||||
}
|
||||
}
|
||||
|
||||
public String CallbackMethodName {
|
||||
get {
|
||||
return _callbackMethodName;
|
||||
}
|
||||
set {
|
||||
_callbackMethodName = value;
|
||||
_callbackMethod = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
643
external/referencesource/System.Configuration/System/Configuration/ClientConfigPaths.cs
vendored
Normal file
643
external/referencesource/System.Configuration/System/Configuration/ClientConfigPaths.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
97
external/referencesource/System.Configuration/System/Configuration/ClientConfigPerf.cs
vendored
Normal file
97
external/referencesource/System.Configuration/System/Configuration/ClientConfigPerf.cs
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="ClientConfigPerf.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Configuration {
|
||||
using System.Configuration.Internal;
|
||||
using System.Globalization;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Threading;
|
||||
using System.Net;
|
||||
using Assembly = System.Reflection.Assembly;
|
||||
using StringBuilder = System.Text.StringBuilder;
|
||||
|
||||
#if NOPERF
|
||||
internal class ClientConfigPerf {
|
||||
const int SIZE=100;
|
||||
|
||||
long[] _counters;
|
||||
long[] _totals;
|
||||
string[] _names;
|
||||
int _current;
|
||||
bool _enabled;
|
||||
|
||||
static internal ClientConfigPerf ConfigSystem = new ClientConfigPerf(false);
|
||||
static internal ClientConfigPerf ScanSections = new ClientConfigPerf(false);
|
||||
static internal ClientConfigPerf CopySection = new ClientConfigPerf(false);
|
||||
static internal ClientConfigPerf CopyXmlNode = new ClientConfigPerf(false);
|
||||
static internal ClientConfigPerf GetConfig = new ClientConfigPerf(true);
|
||||
|
||||
ClientConfigPerf(bool enabled) {
|
||||
#if PERF
|
||||
_enabled = enabled;
|
||||
if (_enabled) {
|
||||
_counters = new long[SIZE];
|
||||
_totals = new long[SIZE];
|
||||
_names = new string[SIZE];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
internal void Reset() {
|
||||
#if PERF
|
||||
_current = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
internal void Record(string name) {
|
||||
#if PERF
|
||||
if (_enabled && _current < _counters.Length) {
|
||||
_names[_current] = name;
|
||||
Microsoft.Win32.SafeNativeMethods.QueryPerformanceCounter(out _counters[_current]);
|
||||
if (_current > 0) {
|
||||
_totals[_current] += _counters[_current] - _counters[_current - 1];
|
||||
}
|
||||
|
||||
_current++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void DoPrint() {
|
||||
#if PERF
|
||||
if (_enabled) {
|
||||
long lfreq = 0;
|
||||
Microsoft.Win32.SafeNativeMethods.QueryPerformanceFrequency(out lfreq);
|
||||
double freq = (double) lfreq;
|
||||
double grandtotal = 0;
|
||||
|
||||
for (int i = 0; i < _current; i++) {
|
||||
double time = ((double)_totals[i]) / freq;
|
||||
grandtotal += time;
|
||||
Console.WriteLine("{0,-20} : {1:F6}", _names[i], time);
|
||||
}
|
||||
|
||||
Console.WriteLine("{0,-20} : {1:F6}\n", "TOTAL", grandtotal);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void Print() {
|
||||
#if PERF
|
||||
ConfigSystem.DoPrint();
|
||||
ScanSections.DoPrint();
|
||||
CopySection.DoPrint();
|
||||
CopyXmlNode.DoPrint();
|
||||
GetConfig.DoPrint();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
624
external/referencesource/System.Configuration/System/Configuration/ClientConfigurationHost.cs
vendored
Normal file
624
external/referencesource/System.Configuration/System/Configuration/ClientConfigurationHost.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
235
external/referencesource/System.Configuration/System/Configuration/ClientConfigurationSystem.cs
vendored
Normal file
235
external/referencesource/System.Configuration/System/Configuration/ClientConfigurationSystem.cs
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="ClientConfigurationSystem.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Configuration {
|
||||
using System.Configuration.Internal;
|
||||
using System.Globalization;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Threading;
|
||||
using System.Net;
|
||||
using Assembly = System.Reflection.Assembly;
|
||||
using StringBuilder = System.Text.StringBuilder;
|
||||
|
||||
internal sealed class ClientConfigurationSystem : IInternalConfigSystem {
|
||||
private const string SystemDiagnosticsConfigKey = "system.diagnostics";
|
||||
private const string SystemNetGroupKey = "system.net/";
|
||||
|
||||
private IConfigSystem _configSystem;
|
||||
private IInternalConfigRoot _configRoot;
|
||||
private ClientConfigurationHost _configHost;
|
||||
private IInternalConfigRecord _machineConfigRecord;
|
||||
private IInternalConfigRecord _completeConfigRecord;
|
||||
private Exception _initError;
|
||||
private bool _isInitInProgress;
|
||||
private bool _isMachineConfigInited;
|
||||
private bool _isUserConfigInited;
|
||||
private bool _isAppConfigHttp;
|
||||
|
||||
|
||||
internal ClientConfigurationSystem() {
|
||||
_configSystem = new ConfigSystem();
|
||||
_configSystem.Init(typeof(ClientConfigurationHost), null, null);
|
||||
|
||||
_configHost = (ClientConfigurationHost) _configSystem.Host;
|
||||
_configRoot = _configSystem.Root;
|
||||
|
||||
_configRoot.ConfigRemoved += OnConfigRemoved;
|
||||
|
||||
_isAppConfigHttp = _configHost.IsAppConfigHttp;
|
||||
|
||||
// VSWhidbey 606116: Config has a dependency on Uri class which has
|
||||
// a new static constructor that calls config. We need a dummy reference
|
||||
// to Uri class so the static constructor would be involved first to
|
||||
// initialize config.
|
||||
string dummy = System.Uri.SchemeDelimiter;
|
||||
}
|
||||
|
||||
// Return true if the section might be used during initialization of the configuration system,
|
||||
// and thus lead to deadlock if appropriate measures are not taken.
|
||||
bool IsSectionUsedInInit(string configKey) {
|
||||
return configKey == SystemDiagnosticsConfigKey || (_isAppConfigHttp && configKey.StartsWith(SystemNetGroupKey, StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
// Return true if the section should only use the machine configuration and not use the
|
||||
// application configuration. This is only true for system.net sections when the configuration
|
||||
// file for the application is downloaded via http using System.Net.WebClient.
|
||||
bool DoesSectionOnlyUseMachineConfig(string configKey) {
|
||||
return _isAppConfigHttp && configKey.StartsWith(SystemNetGroupKey, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
// Ensure that initialization has completed, while handling re-entrancy issues
|
||||
// for certain sections that may be used during initialization itself.
|
||||
void EnsureInit(string configKey) {
|
||||
bool doInit = false;
|
||||
|
||||
lock (this) {
|
||||
// If the user config is not initialized, then we must either:
|
||||
// a. Perform the initialization ourselves if no other thread is doing it, or
|
||||
// b. Wait for the initialization to complete if we know the section is not used during initialization itself, or
|
||||
// c. Ignore initialization if the section can be used during initialization. Note that GetSection()
|
||||
// returns null is initialization has not completed.
|
||||
if (!_isUserConfigInited) {
|
||||
if (!_isInitInProgress) {
|
||||
_isInitInProgress = true;
|
||||
doInit = true;
|
||||
}
|
||||
else if (!IsSectionUsedInInit(configKey)) {
|
||||
// Wait for initialization to complete.
|
||||
Monitor.Wait(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (doInit) {
|
||||
try {
|
||||
try {
|
||||
try {
|
||||
// Initialize machine configuration.
|
||||
_machineConfigRecord = _configRoot.GetConfigRecord(
|
||||
ClientConfigurationHost.MachineConfigPath);
|
||||
|
||||
_machineConfigRecord.ThrowIfInitErrors();
|
||||
|
||||
// Make machine configuration available to system.net sections
|
||||
// when application configuration is downloaded via http.
|
||||
_isMachineConfigInited = true;
|
||||
|
||||
//
|
||||
// Prevent deadlocks in the networking classes by loading
|
||||
// networking config before making a networking request.
|
||||
// Any requests for sections used in initialization during
|
||||
// the call to EnsureConfigLoaded() will be served by
|
||||
// _machine.config or will return null.
|
||||
//
|
||||
if (_isAppConfigHttp) {
|
||||
ConfigurationManagerHelperFactory.Instance.EnsureNetConfigLoaded();
|
||||
}
|
||||
|
||||
//
|
||||
// Now load the rest of configuration
|
||||
//
|
||||
_configHost.RefreshConfigPaths();
|
||||
string configPath;
|
||||
if (_configHost.HasLocalConfig) {
|
||||
configPath = ClientConfigurationHost.LocalUserConfigPath;
|
||||
}
|
||||
else if (_configHost.HasRoamingConfig) {
|
||||
configPath = ClientConfigurationHost.RoamingUserConfigPath;
|
||||
}
|
||||
else {
|
||||
configPath = ClientConfigurationHost.ExeConfigPath;
|
||||
}
|
||||
|
||||
_completeConfigRecord = _configRoot.GetConfigRecord(configPath);
|
||||
_completeConfigRecord.ThrowIfInitErrors();
|
||||
|
||||
_isUserConfigInited = true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
_initError = new ConfigurationErrorsException(SR.GetString(SR.Config_client_config_init_error), e);
|
||||
throw _initError;
|
||||
}
|
||||
}
|
||||
catch {
|
||||
ConfigurationManager.SetInitError(_initError);
|
||||
_isMachineConfigInited = true;
|
||||
_isUserConfigInited = true;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
lock (this) {
|
||||
try {
|
||||
// Notify ConfigurationSettings that initialization has fully completed,
|
||||
// even if unsuccessful.
|
||||
ConfigurationManager.CompleteConfigInit();
|
||||
|
||||
_isInitInProgress = false;
|
||||
|
||||
}
|
||||
finally {
|
||||
// Wake up all threads waiting for initialization to complete.
|
||||
Monitor.PulseAll(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PrepareClientConfigSystem(string sectionName) {
|
||||
// Ensure the configuration system is inited for this section.
|
||||
if (!_isUserConfigInited) {
|
||||
EnsureInit(sectionName);
|
||||
}
|
||||
|
||||
// If an error occurred during initialzation, throw it.
|
||||
if (_initError != null) {
|
||||
throw _initError;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If config has been removed because initialization was not complete,
|
||||
// fetch a new configuration record. The record will be created and
|
||||
// completely initialized as RequireCompleteInit() will have been called
|
||||
// on the ClientConfigurationHost before we receive this event.
|
||||
//
|
||||
private void OnConfigRemoved(object sender, InternalConfigEventArgs e) {
|
||||
try {
|
||||
IInternalConfigRecord newConfigRecord = _configRoot.GetConfigRecord(_completeConfigRecord.ConfigPath);
|
||||
_completeConfigRecord = newConfigRecord;
|
||||
_completeConfigRecord.ThrowIfInitErrors();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
_initError = new ConfigurationErrorsException(SR.GetString(SR.Config_client_config_init_error), ex);
|
||||
ConfigurationManager.SetInitError(_initError);
|
||||
throw _initError;
|
||||
}
|
||||
}
|
||||
|
||||
object IInternalConfigSystem.GetSection(string sectionName) {
|
||||
PrepareClientConfigSystem(sectionName);
|
||||
|
||||
// Get the appropriate config record for the section.
|
||||
IInternalConfigRecord configRecord = null;
|
||||
if (DoesSectionOnlyUseMachineConfig(sectionName)) {
|
||||
if (_isMachineConfigInited) {
|
||||
configRecord = _machineConfigRecord;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (_isUserConfigInited) {
|
||||
configRecord = _completeConfigRecord;
|
||||
}
|
||||
}
|
||||
|
||||
// Call GetSection(), or return null if no configuration is yet available.
|
||||
if (configRecord != null) {
|
||||
return configRecord.GetSection(sectionName);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void IInternalConfigSystem.RefreshConfig(string sectionName) {
|
||||
PrepareClientConfigSystem(sectionName);
|
||||
|
||||
if (_isMachineConfigInited) {
|
||||
_machineConfigRecord.RefreshSection(sectionName);
|
||||
}
|
||||
}
|
||||
|
||||
// Supports user config
|
||||
bool IInternalConfigSystem.SupportsUserConfig {
|
||||
get {return true;}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="CommaDelimitedStringCollectionConverter.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Security.Permissions;
|
||||
using System.Xml;
|
||||
using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
using System.ComponentModel;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
|
||||
namespace System.Configuration {
|
||||
|
||||
public sealed class CommaDelimitedStringCollectionConverter : ConfigurationConverterBase {
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type) {
|
||||
|
||||
ValidateType(value, typeof(CommaDelimitedStringCollection));
|
||||
CommaDelimitedStringCollection internalValue = value as CommaDelimitedStringCollection;
|
||||
if (internalValue != null) {
|
||||
return internalValue.ToString();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data) {
|
||||
CommaDelimitedStringCollection attributeCollection = new CommaDelimitedStringCollection();
|
||||
attributeCollection.FromString((string)data);
|
||||
return attributeCollection;
|
||||
}
|
||||
}
|
||||
}
|
72
external/referencesource/System.Configuration/System/Configuration/ConfigDefinitionUpdates.cs
vendored
Normal file
72
external/referencesource/System.Configuration/System/Configuration/ConfigDefinitionUpdates.cs
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="ConfigDefinitionUpdates.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Configuration {
|
||||
using System.Collections;
|
||||
|
||||
//
|
||||
// Contains all the updates to section definitions across all location sections.
|
||||
//
|
||||
internal class ConfigDefinitionUpdates {
|
||||
private ArrayList _locationUpdatesList;
|
||||
private bool _requireLocationWritten;
|
||||
|
||||
internal ConfigDefinitionUpdates() {
|
||||
_locationUpdatesList = new ArrayList();
|
||||
}
|
||||
|
||||
//
|
||||
// Find the location update with a certain set of location attributes.
|
||||
//
|
||||
internal LocationUpdates FindLocationUpdates(OverrideModeSetting overrideMode, bool inheritInChildApps) {
|
||||
foreach (LocationUpdates locationUpdates in _locationUpdatesList) {
|
||||
if ( OverrideModeSetting.CanUseSameLocationTag(locationUpdates.OverrideMode, overrideMode) &&
|
||||
locationUpdates.InheritInChildApps == inheritInChildApps) {
|
||||
return locationUpdates;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//
|
||||
// Add a section definition update to the correct location update.
|
||||
//
|
||||
internal DefinitionUpdate AddUpdate(OverrideModeSetting overrideMode, bool inheritInChildApps, bool moved, string updatedXml, SectionRecord sectionRecord) {
|
||||
LocationUpdates locationUpdates = FindLocationUpdates(overrideMode, inheritInChildApps);
|
||||
if (locationUpdates == null) {
|
||||
locationUpdates = new LocationUpdates(overrideMode, inheritInChildApps);
|
||||
_locationUpdatesList.Add(locationUpdates);
|
||||
}
|
||||
|
||||
DefinitionUpdate definitionUpdate = new DefinitionUpdate(sectionRecord.ConfigKey, moved, updatedXml, sectionRecord);
|
||||
locationUpdates.SectionUpdates.AddSection(definitionUpdate);
|
||||
return definitionUpdate;
|
||||
}
|
||||
|
||||
//
|
||||
// Determine which section definition updates are new.
|
||||
//
|
||||
internal void CompleteUpdates() {
|
||||
foreach (LocationUpdates locationUpdates in _locationUpdatesList) {
|
||||
locationUpdates.CompleteUpdates();
|
||||
}
|
||||
}
|
||||
|
||||
internal ArrayList LocationUpdatesList {
|
||||
get {return _locationUpdatesList;}
|
||||
}
|
||||
|
||||
internal bool RequireLocation {
|
||||
get { return _requireLocationWritten; }
|
||||
set { _requireLocationWritten = value; }
|
||||
}
|
||||
|
||||
internal void FlagLocationWritten() {
|
||||
_requireLocationWritten = false;
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user