You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@ -0,0 +1,41 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace System.Runtime.Serialization.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
internal static class ConfigurationStrings
|
||||
{
|
||||
static string GetSectionPath(string sectionName)
|
||||
{
|
||||
return string.Concat(ConfigurationStrings.SectionGroupName, "/", sectionName);
|
||||
}
|
||||
|
||||
static internal string DataContractSerializerSectionPath
|
||||
{
|
||||
get { return ConfigurationStrings.GetSectionPath(ConfigurationStrings.DataContractSerializerSectionName); }
|
||||
}
|
||||
|
||||
static internal string NetDataContractSerializerSectionPath
|
||||
{
|
||||
get { return ConfigurationStrings.GetSectionPath(ConfigurationStrings.NetDataContractSerializerSectionName); }
|
||||
}
|
||||
|
||||
internal const string SectionGroupName = "system.runtime.serialization";
|
||||
|
||||
internal const string DefaultCollectionName = ""; // String.Empty
|
||||
internal const string DeclaredTypes = "declaredTypes";
|
||||
internal const string Index = "index";
|
||||
internal const string Parameter = "parameter";
|
||||
internal const string Type = "type";
|
||||
internal const string EnableUnsafeTypeForwarding = "enableUnsafeTypeForwarding";
|
||||
internal const string DataContractSerializerSectionName = "dataContractSerializer";
|
||||
internal const string NetDataContractSerializerSectionName = "netDataContractSerializer";
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace System.Runtime.Serialization.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Globalization;
|
||||
using System.Security.Permissions;
|
||||
using System.Security;
|
||||
|
||||
public sealed partial class DataContractSerializerSection : ConfigurationSection
|
||||
{
|
||||
public DataContractSerializerSection()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
[Fx.Tag.SecurityNote(Critical = "Elevates in order to get the DataContractSerializerSection config section."
|
||||
+ " Caller should not leak config section instance to untrusted code.")]
|
||||
[SecurityCritical]
|
||||
[ConfigurationPermission(SecurityAction.Assert, Unrestricted = true)]
|
||||
internal static DataContractSerializerSection UnsafeGetSection()
|
||||
{
|
||||
DataContractSerializerSection section =
|
||||
(DataContractSerializerSection)ConfigurationManager.GetSection(ConfigurationStrings.DataContractSerializerSectionPath);
|
||||
if (section == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigDataContractSerializerSectionLoadError)));
|
||||
}
|
||||
return section;
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.DeclaredTypes, DefaultValue = null)]
|
||||
public DeclaredTypeElementCollection DeclaredTypes
|
||||
{
|
||||
get { return (DeclaredTypeElementCollection)base[ConfigurationStrings.DeclaredTypes]; }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,61 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace System.Runtime.Serialization.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Security.Permissions;
|
||||
using System.Security;
|
||||
|
||||
public sealed partial class DeclaredTypeElement : ConfigurationElement
|
||||
{
|
||||
public DeclaredTypeElement()
|
||||
{
|
||||
}
|
||||
|
||||
public DeclaredTypeElement(string typeName)
|
||||
: this()
|
||||
{
|
||||
if (String.IsNullOrEmpty(typeName))
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName");
|
||||
}
|
||||
this.Type = typeName;
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.DefaultCollectionName, DefaultValue = null, Options = ConfigurationPropertyOptions.IsDefaultCollection)]
|
||||
public TypeElementCollection KnownTypes
|
||||
{
|
||||
get { return (TypeElementCollection)base[ConfigurationStrings.DefaultCollectionName]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.Type, DefaultValue = "", Options = ConfigurationPropertyOptions.IsKey)]
|
||||
[DeclaredTypeValidator()]
|
||||
public string Type
|
||||
{
|
||||
get { return (string)base[ConfigurationStrings.Type]; }
|
||||
set { base[ConfigurationStrings.Type] = value; }
|
||||
}
|
||||
|
||||
[Fx.Tag.SecurityNote(Critical = "Calls the critical methods of PartialTrustHelpers",
|
||||
Safe = "PartialTrustHelpers.IsInFullTrust demands for FullTrust")]
|
||||
[SecuritySafeCritical]
|
||||
protected override void PostDeserialize()
|
||||
{
|
||||
// Perf optimization. If the configuration is coming from machine.config
|
||||
// It is safe and we don't need to check for permissions.
|
||||
if (EvaluationContext.IsMachineLevel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!PartialTrustHelpers.IsInFullTrust())
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigDataContractSerializerSectionLoadError)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,174 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace System.Runtime.Serialization.Configuration
|
||||
{
|
||||
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Globalization;
|
||||
|
||||
[ConfigurationCollection(typeof(DeclaredTypeElement))]
|
||||
public sealed class DeclaredTypeElementCollection : ConfigurationElementCollection
|
||||
{
|
||||
public DeclaredTypeElementCollection()
|
||||
{
|
||||
}
|
||||
|
||||
public DeclaredTypeElement this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
DeclaredTypeElement retval = (DeclaredTypeElement)BaseGet(index);
|
||||
return retval;
|
||||
}
|
||||
set
|
||||
{
|
||||
// Only validate input if config is not Read-Only, otherwise
|
||||
// let BaseAdd throw appropriate exception
|
||||
if (!this.IsReadOnly())
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
|
||||
}
|
||||
|
||||
if (BaseGet(index) != null)
|
||||
{
|
||||
BaseRemoveAt(index);
|
||||
}
|
||||
}
|
||||
BaseAdd(index, value);
|
||||
}
|
||||
}
|
||||
|
||||
public new DeclaredTypeElement this[string typeName]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (String.IsNullOrEmpty(typeName))
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName");
|
||||
}
|
||||
DeclaredTypeElement retval = (DeclaredTypeElement)BaseGet(typeName);
|
||||
return retval;
|
||||
}
|
||||
set
|
||||
{
|
||||
// Only validate input if config is not Read-Only, otherwise
|
||||
// let Add throw appropriate exception
|
||||
if (!this.IsReadOnly())
|
||||
{
|
||||
if (String.IsNullOrEmpty(typeName))
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName");
|
||||
}
|
||||
if (value == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
|
||||
}
|
||||
if (BaseGet(typeName) != null)
|
||||
{
|
||||
BaseRemove(typeName);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new IndexOutOfRangeException(SR.GetString(SR.ConfigIndexOutOfRange,
|
||||
typeName)));
|
||||
}
|
||||
}
|
||||
Add(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(DeclaredTypeElement element)
|
||||
{
|
||||
// Only validate input if config is not Read-Only, otherwise
|
||||
// let BaseAdd throw appropriate exception
|
||||
if (!this.IsReadOnly())
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
|
||||
}
|
||||
}
|
||||
BaseAdd(element);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
BaseClear();
|
||||
}
|
||||
|
||||
public bool Contains(string typeName)
|
||||
{
|
||||
if (String.IsNullOrEmpty(typeName))
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName");
|
||||
}
|
||||
return this.BaseGet(typeName) != null;
|
||||
}
|
||||
|
||||
protected override ConfigurationElement CreateNewElement()
|
||||
{
|
||||
DeclaredTypeElement retval = new DeclaredTypeElement();
|
||||
return retval;
|
||||
}
|
||||
|
||||
protected override Object GetElementKey(ConfigurationElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
|
||||
}
|
||||
return ((DeclaredTypeElement)element).Type;
|
||||
}
|
||||
|
||||
public int IndexOf(DeclaredTypeElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
|
||||
}
|
||||
return BaseIndexOf(element);
|
||||
}
|
||||
|
||||
public void Remove(DeclaredTypeElement element)
|
||||
{
|
||||
// Only validate input if config is not Read-Only, otherwise
|
||||
// let BaseRemove throw appropriate exception
|
||||
if (!this.IsReadOnly())
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
|
||||
}
|
||||
}
|
||||
BaseRemove(this.GetElementKey(element));
|
||||
}
|
||||
|
||||
public void Remove(string typeName)
|
||||
{
|
||||
// Only validate input if config is not Read-Only, otherwise
|
||||
// let BaseRemove throw appropriate exception
|
||||
if (!this.IsReadOnly())
|
||||
{
|
||||
if (String.IsNullOrEmpty(typeName))
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName");
|
||||
}
|
||||
}
|
||||
BaseRemove(typeName);
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
BaseRemoveAt(index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Runtime.Serialization.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
internal class DeclaredTypeValidator : ConfigurationValidatorBase
|
||||
{
|
||||
public override bool CanValidate(Type type)
|
||||
{
|
||||
return (typeof(string) == type);
|
||||
}
|
||||
|
||||
public override void Validate(object value)
|
||||
{
|
||||
string type = (string)value;
|
||||
|
||||
if (type.StartsWith(Globals.TypeOfObject.FullName, StringComparison.Ordinal))
|
||||
{
|
||||
Type t = Type.GetType(type, false);
|
||||
if (t != null && Globals.TypeOfObject.Equals(t))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.KnownTypeConfigObject));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Runtime.Serialization.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
internal sealed class DeclaredTypeValidatorAttribute : ConfigurationValidatorAttribute
|
||||
{
|
||||
public override ConfigurationValidatorBase ValidatorInstance
|
||||
{
|
||||
get { return new DeclaredTypeValidator(); }
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace System.Runtime.Serialization.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Globalization;
|
||||
using System.Security.Permissions;
|
||||
using System.Security;
|
||||
|
||||
public sealed partial class NetDataContractSerializerSection : ConfigurationSection
|
||||
{
|
||||
public NetDataContractSerializerSection()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
[Fx.Tag.SecurityNote(Critical = "Elevates in order to get the NetDataContractSerializerSection config section."
|
||||
+ " Caller should not leak config section instance to untrusted code.")]
|
||||
[SecurityCritical]
|
||||
[ConfigurationPermission(SecurityAction.Assert, Unrestricted = true)]
|
||||
internal static bool TryUnsafeGetSection(out NetDataContractSerializerSection section)
|
||||
{
|
||||
section = (NetDataContractSerializerSection)ConfigurationManager.GetSection(ConfigurationStrings.NetDataContractSerializerSectionPath);
|
||||
return section != null;
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.EnableUnsafeTypeForwarding, DefaultValue = false)]
|
||||
public bool EnableUnsafeTypeForwarding
|
||||
{
|
||||
get { return (bool)base[ConfigurationStrings.EnableUnsafeTypeForwarding]; }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace System.Runtime.Serialization.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Xml;
|
||||
using System.Security;
|
||||
|
||||
public sealed partial class ParameterElement : ConfigurationElement
|
||||
{
|
||||
public ParameterElement()
|
||||
{
|
||||
}
|
||||
|
||||
public ParameterElement(string typeName)
|
||||
: this()
|
||||
{
|
||||
if (String.IsNullOrEmpty(typeName))
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName");
|
||||
}
|
||||
this.Type = typeName;
|
||||
}
|
||||
|
||||
public ParameterElement(int index)
|
||||
: this()
|
||||
{
|
||||
this.Index = index;
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.Index, DefaultValue = 0)]
|
||||
[IntegerValidator(MinValue = 0)]
|
||||
public int Index
|
||||
{
|
||||
get { return (int)base[ConfigurationStrings.Index]; }
|
||||
set { base[ConfigurationStrings.Index] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.DefaultCollectionName, DefaultValue = null, Options = ConfigurationPropertyOptions.IsDefaultCollection)]
|
||||
public ParameterElementCollection Parameters
|
||||
{
|
||||
get { return (ParameterElementCollection)base[ConfigurationStrings.DefaultCollectionName]; }
|
||||
}
|
||||
|
||||
protected override void PostDeserialize()
|
||||
{
|
||||
this.Validate();
|
||||
}
|
||||
|
||||
protected override void PreSerialize(XmlWriter writer)
|
||||
{
|
||||
this.Validate();
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.Type, DefaultValue = "")]
|
||||
[StringValidator(MinLength = 0)]
|
||||
public string Type
|
||||
{
|
||||
get { return (string)base[ConfigurationStrings.Type]; }
|
||||
set
|
||||
{
|
||||
if (String.IsNullOrEmpty(value))
|
||||
{
|
||||
value = String.Empty;
|
||||
}
|
||||
base[ConfigurationStrings.Type] = value;
|
||||
}
|
||||
}
|
||||
|
||||
void Validate()
|
||||
{
|
||||
PropertyInformationCollection propertyInfo = this.ElementInformation.Properties;
|
||||
if ((propertyInfo[ConfigurationStrings.Index].ValueOrigin == PropertyValueOrigin.Default) &&
|
||||
(propertyInfo[ConfigurationStrings.Type].ValueOrigin == PropertyValueOrigin.Default))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(
|
||||
SR.GetString(SR.ConfigMustSetTypeOrIndex)));
|
||||
}
|
||||
|
||||
if ((propertyInfo[ConfigurationStrings.Index].ValueOrigin != PropertyValueOrigin.Default) &&
|
||||
(propertyInfo[ConfigurationStrings.Type].ValueOrigin != PropertyValueOrigin.Default))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(
|
||||
SR.GetString(SR.ConfigMustOnlySetTypeOrIndex)));
|
||||
}
|
||||
|
||||
if ((propertyInfo[ConfigurationStrings.Index].ValueOrigin != PropertyValueOrigin.Default) && this.Parameters.Count > 0)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(
|
||||
SR.GetString(SR.ConfigMustOnlyAddParamsWithType)));
|
||||
}
|
||||
}
|
||||
|
||||
internal readonly Guid identity = Guid.NewGuid();
|
||||
|
||||
[Fx.Tag.SecurityNote(Miscellaneous = "RequiresReview - Loads type given name in configuration."
|
||||
+ " Since this information is used to determine whether a particular type is included as a known type,"
|
||||
+ " changes to the logic should be reviewed.")]
|
||||
internal Type GetType(string rootType, Type[] typeArgs)
|
||||
{
|
||||
return TypeElement.GetType(rootType, typeArgs, this.Type, this.Index, this.Parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,132 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace System.Runtime.Serialization.Configuration
|
||||
{
|
||||
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Globalization;
|
||||
|
||||
[ConfigurationCollection(typeof(ParameterElement), AddItemName = ConfigurationStrings.Parameter, CollectionType = ConfigurationElementCollectionType.BasicMap)]
|
||||
public sealed class ParameterElementCollection : ConfigurationElementCollection
|
||||
{
|
||||
public ParameterElementCollection()
|
||||
{
|
||||
this.AddElementName = ConfigurationStrings.Parameter;
|
||||
}
|
||||
|
||||
public ParameterElement this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
ParameterElement retval = (ParameterElement)BaseGet(index);
|
||||
return retval;
|
||||
}
|
||||
set
|
||||
{
|
||||
// Only validate input if config is not Read-Only, otherwise
|
||||
// let BaseAdd throw appropriate exception
|
||||
if (!this.IsReadOnly())
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
|
||||
}
|
||||
if (BaseGet(index) != null)
|
||||
{
|
||||
BaseRemoveAt(index);
|
||||
}
|
||||
}
|
||||
BaseAdd(index, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Add(ParameterElement element)
|
||||
{
|
||||
// Only validate input if config is not Read-Only, otherwise
|
||||
// let BaseAdd throw appropriate exception
|
||||
if (!this.IsReadOnly())
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
|
||||
}
|
||||
}
|
||||
BaseAdd(element);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
BaseClear();
|
||||
}
|
||||
|
||||
public override ConfigurationElementCollectionType CollectionType
|
||||
{
|
||||
get { return ConfigurationElementCollectionType.BasicMap; }
|
||||
}
|
||||
|
||||
public bool Contains(string typeName)
|
||||
{
|
||||
if (String.IsNullOrEmpty(typeName))
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName");
|
||||
}
|
||||
return this.BaseGet(typeName) != null;
|
||||
}
|
||||
|
||||
protected override ConfigurationElement CreateNewElement()
|
||||
{
|
||||
ParameterElement retval = new ParameterElement();
|
||||
return retval;
|
||||
}
|
||||
|
||||
protected override string ElementName
|
||||
{
|
||||
get { return ConfigurationStrings.Parameter; }
|
||||
}
|
||||
|
||||
protected override Object GetElementKey(ConfigurationElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
|
||||
}
|
||||
|
||||
return ((ParameterElement)element).identity;
|
||||
}
|
||||
|
||||
public int IndexOf(ParameterElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
|
||||
}
|
||||
return BaseIndexOf(element);
|
||||
}
|
||||
|
||||
public void Remove(ParameterElement element)
|
||||
{
|
||||
// Only validate input if config is not Read-Only, otherwise
|
||||
// let BaseRemove throw appropriate exception
|
||||
if (!this.IsReadOnly())
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
|
||||
}
|
||||
}
|
||||
BaseRemove(this.GetElementKey(element));
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
BaseRemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,147 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// This code was produced by a tool, ConfigPropertyGenerator.exe, by reflecting over
|
||||
// System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
|
||||
// Please add this file to the project that built the assembly.
|
||||
// Doing so will provide better performance for retrieving the ConfigurationElement Properties.
|
||||
// If compilation errors occur, make sure that the Properties property has not
|
||||
// already been provided. If it has, decide if you want the version produced by
|
||||
// this tool or by the developer.
|
||||
// If build errors result, make sure the config class is marked with the partial keyword.
|
||||
|
||||
// To regenerate a new Properties.cs after changes to the configuration OM for
|
||||
// this assembly, simply run Indigo\Suites\Configuration\Infrastructure\ConfigPropertyGenerator.
|
||||
// If any changes affect this file, the suite will fail. Instructions on how to
|
||||
// update Properties.cs will be included in the tests output file (ConfigPropertyGenerator.out).
|
||||
|
||||
using System.Configuration;
|
||||
using System.Globalization;
|
||||
|
||||
|
||||
// configType.Name: DeclaredTypeElement
|
||||
|
||||
namespace System.Runtime.Serialization.Configuration
|
||||
{
|
||||
public sealed partial class DeclaredTypeElement
|
||||
{
|
||||
ConfigurationPropertyCollection properties;
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.properties == null)
|
||||
{
|
||||
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
|
||||
properties.Add(new ConfigurationProperty("", typeof(System.Runtime.Serialization.Configuration.TypeElementCollection), null, null, null, System.Configuration.ConfigurationPropertyOptions.IsDefaultCollection));
|
||||
properties.Add(new ConfigurationProperty("type", typeof(System.String), string.Empty, null, new System.Runtime.Serialization.Configuration.DeclaredTypeValidator(), System.Configuration.ConfigurationPropertyOptions.IsKey));
|
||||
this.properties = properties;
|
||||
}
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// configType.Name: NetDataContractSerializerSection
|
||||
|
||||
namespace System.Runtime.Serialization.Configuration
|
||||
{
|
||||
public sealed partial class NetDataContractSerializerSection
|
||||
{
|
||||
ConfigurationPropertyCollection properties;
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.properties == null)
|
||||
{
|
||||
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
|
||||
properties.Add(new ConfigurationProperty("enableUnsafeTypeForwarding", typeof(System.Boolean), false, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
this.properties = properties;
|
||||
}
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// configType.Name: ParameterElement
|
||||
|
||||
namespace System.Runtime.Serialization.Configuration
|
||||
{
|
||||
public sealed partial class ParameterElement
|
||||
{
|
||||
ConfigurationPropertyCollection properties;
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.properties == null)
|
||||
{
|
||||
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
|
||||
properties.Add(new ConfigurationProperty("index", typeof(System.Int32), 0, null, new System.Configuration.IntegerValidator(0, 2147483647, false), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty("", typeof(System.Runtime.Serialization.Configuration.ParameterElementCollection), null, null, null, System.Configuration.ConfigurationPropertyOptions.IsDefaultCollection));
|
||||
properties.Add(new ConfigurationProperty("type", typeof(System.String), string.Empty, null, new System.Configuration.StringValidator(0, 2147483647, null), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
this.properties = properties;
|
||||
}
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// configType.Name: DataContractSerializerSection
|
||||
|
||||
namespace System.Runtime.Serialization.Configuration
|
||||
{
|
||||
public sealed partial class DataContractSerializerSection
|
||||
{
|
||||
ConfigurationPropertyCollection properties;
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.properties == null)
|
||||
{
|
||||
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
|
||||
properties.Add(new ConfigurationProperty("declaredTypes", typeof(System.Runtime.Serialization.Configuration.DeclaredTypeElementCollection), null, null, null, System.Configuration.ConfigurationPropertyOptions.None));
|
||||
this.properties = properties;
|
||||
}
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// configType.Name: TypeElement
|
||||
|
||||
namespace System.Runtime.Serialization.Configuration
|
||||
{
|
||||
public sealed partial class TypeElement
|
||||
{
|
||||
ConfigurationPropertyCollection properties;
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.properties == null)
|
||||
{
|
||||
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
|
||||
properties.Add(new ConfigurationProperty("", typeof(System.Runtime.Serialization.Configuration.ParameterElementCollection), null, null, null, System.Configuration.ConfigurationPropertyOptions.IsDefaultCollection));
|
||||
properties.Add(new ConfigurationProperty("type", typeof(System.String), string.Empty, null, new System.Configuration.StringValidator(0, 2147483647, null), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
properties.Add(new ConfigurationProperty("index", typeof(System.Int32), 0, null, new System.Configuration.IntegerValidator(0, 2147483647, false), System.Configuration.ConfigurationPropertyOptions.None));
|
||||
this.properties = properties;
|
||||
}
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace System.Runtime.Serialization.Configuration
|
||||
{
|
||||
using System.Configuration;
|
||||
|
||||
public sealed class SerializationSectionGroup : ConfigurationSectionGroup
|
||||
{
|
||||
static public SerializationSectionGroup GetSectionGroup(Configuration config)
|
||||
{
|
||||
if (config == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("config");
|
||||
}
|
||||
#pragma warning suppress 56506 // [....], config is checked above
|
||||
return (SerializationSectionGroup)config.SectionGroups[ConfigurationStrings.SectionGroupName];
|
||||
}
|
||||
|
||||
public DataContractSerializerSection DataContractSerializer
|
||||
{
|
||||
get { return (DataContractSerializerSection)this.Sections[ConfigurationStrings.DataContractSerializerSectionName]; }
|
||||
}
|
||||
|
||||
public NetDataContractSerializerSection NetDataContractSerializer
|
||||
{
|
||||
get { return (NetDataContractSerializerSection)this.Sections[ConfigurationStrings.NetDataContractSerializerSectionName]; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,122 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace System.Runtime.Serialization.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Diagnostics;
|
||||
using System.ServiceModel.Diagnostics;
|
||||
using System.Security;
|
||||
|
||||
public sealed partial class TypeElement : ConfigurationElement
|
||||
{
|
||||
public TypeElement()
|
||||
{
|
||||
}
|
||||
|
||||
public TypeElement(string typeName)
|
||||
: this()
|
||||
{
|
||||
if (String.IsNullOrEmpty(typeName))
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName");
|
||||
}
|
||||
this.Type = typeName;
|
||||
}
|
||||
|
||||
internal string Key
|
||||
{
|
||||
get { return this.key; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.DefaultCollectionName, DefaultValue = null, Options = ConfigurationPropertyOptions.IsDefaultCollection)]
|
||||
public ParameterElementCollection Parameters
|
||||
{
|
||||
get { return (ParameterElementCollection)base[ConfigurationStrings.DefaultCollectionName]; }
|
||||
}
|
||||
|
||||
protected override void Reset(ConfigurationElement parentElement)
|
||||
{
|
||||
TypeElement parent = (TypeElement)parentElement;
|
||||
this.key = parent.key;
|
||||
base.Reset(parentElement);
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.Type, DefaultValue = "")]
|
||||
[StringValidator(MinLength = 0)]
|
||||
public string Type
|
||||
{
|
||||
get { return (string)base[ConfigurationStrings.Type]; }
|
||||
set { base[ConfigurationStrings.Type] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.Index, DefaultValue = 0)]
|
||||
[IntegerValidator(MinValue = 0)]
|
||||
public int Index
|
||||
{
|
||||
get { return (int)base[ConfigurationStrings.Index]; }
|
||||
set { base[ConfigurationStrings.Index] = value; }
|
||||
}
|
||||
|
||||
[Fx.Tag.SecurityNote(Miscellaneous = "RequiresReview - Loads type given name in configuration."
|
||||
+ " Since this information is used to determine whether a particular type is included as a known type,"
|
||||
+ " changes to the logic should be reviewed.")]
|
||||
internal Type GetType(string rootType, Type[] typeArgs)
|
||||
{
|
||||
return GetType(rootType, typeArgs, this.Type, this.Index, this.Parameters);
|
||||
}
|
||||
|
||||
[Fx.Tag.SecurityNote(Miscellaneous = "RequiresReview - Loads type given name in configuration."
|
||||
+ " Since this information is used to determine whether a particular type is included as a known type,"
|
||||
+ " changes to the logic should be reviewed.")]
|
||||
internal static Type GetType(string rootType, Type[] typeArgs, string type, int index, ParameterElementCollection parameters)
|
||||
{
|
||||
if (String.IsNullOrEmpty(type))
|
||||
{
|
||||
if (typeArgs == null || index >= typeArgs.Length)
|
||||
{
|
||||
int typeArgsCount = typeArgs == null ? 0 : typeArgs.Length;
|
||||
if (typeArgsCount == 0)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.KnownTypeConfigIndexOutOfBoundsZero,
|
||||
rootType,
|
||||
typeArgsCount,
|
||||
index));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.KnownTypeConfigIndexOutOfBounds,
|
||||
rootType,
|
||||
typeArgsCount,
|
||||
index));
|
||||
}
|
||||
}
|
||||
|
||||
return typeArgs[index];
|
||||
}
|
||||
|
||||
Type t = System.Type.GetType(type, true);
|
||||
if (t.IsGenericTypeDefinition)
|
||||
{
|
||||
if (parameters.Count != t.GetGenericArguments().Length)
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.KnownTypeConfigGenericParamMismatch,
|
||||
type,
|
||||
t.GetGenericArguments().Length,
|
||||
parameters.Count));
|
||||
|
||||
Type[] types = new Type[parameters.Count];
|
||||
for (int i = 0; i < types.Length; ++i)
|
||||
{
|
||||
types[i] = parameters[i].GetType(rootType, typeArgs);
|
||||
}
|
||||
t = t.MakeGenericType(types);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
string key = Guid.NewGuid().ToString();
|
||||
}
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace System.Runtime.Serialization.Configuration
|
||||
{
|
||||
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Globalization;
|
||||
|
||||
[ConfigurationCollection(typeof(TypeElement), CollectionType = ConfigurationElementCollectionType.BasicMap)]
|
||||
public sealed class TypeElementCollection : ConfigurationElementCollection
|
||||
{
|
||||
public TypeElementCollection()
|
||||
{
|
||||
}
|
||||
|
||||
public TypeElement this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
TypeElement retval = (TypeElement)BaseGet(index);
|
||||
return retval;
|
||||
}
|
||||
set
|
||||
{
|
||||
// Only validate input if config is not Read-Only, otherwise
|
||||
// let BaseAdd throw appropriate exception
|
||||
if (!this.IsReadOnly())
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
|
||||
}
|
||||
if (BaseGet(index) != null)
|
||||
{
|
||||
BaseRemoveAt(index);
|
||||
}
|
||||
}
|
||||
BaseAdd(index, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(TypeElement element)
|
||||
{
|
||||
// Only validate input if config is not Read-Only, otherwise
|
||||
// let BaseAdd throw appropriate exception
|
||||
if (!this.IsReadOnly())
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
|
||||
}
|
||||
}
|
||||
BaseAdd(element);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
BaseClear();
|
||||
}
|
||||
|
||||
public override ConfigurationElementCollectionType CollectionType
|
||||
{
|
||||
get { return ConfigurationElementCollectionType.BasicMap; }
|
||||
}
|
||||
|
||||
protected override ConfigurationElement CreateNewElement()
|
||||
{
|
||||
TypeElement retval = new TypeElement();
|
||||
return retval;
|
||||
}
|
||||
|
||||
protected override string ElementName
|
||||
{
|
||||
get { return TypeElementCollection.KnownTypeConfig; }
|
||||
}
|
||||
|
||||
protected override Object GetElementKey(ConfigurationElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
|
||||
}
|
||||
return ((TypeElement)element).Key;
|
||||
}
|
||||
|
||||
public int IndexOf(TypeElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
|
||||
}
|
||||
return BaseIndexOf(element);
|
||||
}
|
||||
|
||||
public void Remove(TypeElement element)
|
||||
{
|
||||
// Only validate input if config is not Read-Only, otherwise
|
||||
// let BaseRemove throw appropriate exception
|
||||
if (!this.IsReadOnly())
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
|
||||
}
|
||||
}
|
||||
BaseRemove(this.GetElementKey(element));
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
BaseRemoveAt(index);
|
||||
}
|
||||
|
||||
const string KnownTypeConfig = "knownType";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user