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,69 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="ConfigurationStrings.cs" company="Microsoft Corporation">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
// <owner current="true" primary="true">[....]</owner>
|
||||
//------------------------------------------------------------------------------
|
||||
namespace System.Xml.Serialization.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Globalization;
|
||||
|
||||
internal static class ConfigurationStrings
|
||||
{
|
||||
static string GetSectionPath(string sectionName)
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, @"{0}/{1}", ConfigurationStrings.SectionGroupName, sectionName);
|
||||
}
|
||||
|
||||
static internal string SchemaImporterExtensionsSectionPath
|
||||
{
|
||||
get { return ConfigurationStrings.GetSectionPath(ConfigurationStrings.SchemaImporterExtensionsSectionName); }
|
||||
}
|
||||
|
||||
static internal string DateTimeSerializationSectionPath
|
||||
{
|
||||
get { return ConfigurationStrings.GetSectionPath(ConfigurationStrings.DateTimeSerializationSectionName); }
|
||||
}
|
||||
|
||||
static internal string XmlSerializerSectionPath
|
||||
{
|
||||
get { return ConfigurationStrings.GetSectionPath(ConfigurationStrings.XmlSerializerSectionName); }
|
||||
}
|
||||
|
||||
internal const string Name = "name";
|
||||
internal const string SchemaImporterExtensionsSectionName = "schemaImporterExtensions";
|
||||
internal const string DateTimeSerializationSectionName = "dateTimeSerialization";
|
||||
internal const string XmlSerializerSectionName = "xmlSerializer";
|
||||
internal const string SectionGroupName = "system.xml.serialization";
|
||||
internal const string SqlTypesSchemaImporterChar = "SqlTypesSchemaImporterChar";
|
||||
internal const string SqlTypesSchemaImporterNChar = "SqlTypesSchemaImporterNChar";
|
||||
internal const string SqlTypesSchemaImporterVarChar = "SqlTypesSchemaImporterVarChar";
|
||||
internal const string SqlTypesSchemaImporterNVarChar = "SqlTypesSchemaImporterNVarChar";
|
||||
internal const string SqlTypesSchemaImporterText = "SqlTypesSchemaImporterText";
|
||||
internal const string SqlTypesSchemaImporterNText = "SqlTypesSchemaImporterNText";
|
||||
internal const string SqlTypesSchemaImporterVarBinary = "SqlTypesSchemaImporterVarBinary";
|
||||
internal const string SqlTypesSchemaImporterBinary = "SqlTypesSchemaImporterBinary";
|
||||
internal const string SqlTypesSchemaImporterImage = "SqlTypesSchemaImporterImage";
|
||||
internal const string SqlTypesSchemaImporterDecimal = "SqlTypesSchemaImporterDecimal";
|
||||
internal const string SqlTypesSchemaImporterNumeric = "SqlTypesSchemaImporterNumeric";
|
||||
internal const string SqlTypesSchemaImporterBigInt = "SqlTypesSchemaImporterBigInt";
|
||||
internal const string SqlTypesSchemaImporterInt = "SqlTypesSchemaImporterInt";
|
||||
internal const string SqlTypesSchemaImporterSmallInt = "SqlTypesSchemaImporterSmallInt";
|
||||
internal const string SqlTypesSchemaImporterTinyInt = "SqlTypesSchemaImporterTinyInt";
|
||||
internal const string SqlTypesSchemaImporterBit = "SqlTypesSchemaImporterBit";
|
||||
internal const string SqlTypesSchemaImporterFloat = "SqlTypesSchemaImporterFloat";
|
||||
internal const string SqlTypesSchemaImporterReal = "SqlTypesSchemaImporterReal";
|
||||
internal const string SqlTypesSchemaImporterDateTime = "SqlTypesSchemaImporterDateTime";
|
||||
internal const string SqlTypesSchemaImporterSmallDateTime = "SqlTypesSchemaImporterSmallDateTime";
|
||||
internal const string SqlTypesSchemaImporterMoney = "SqlTypesSchemaImporterMoney";
|
||||
internal const string SqlTypesSchemaImporterSmallMoney = "SqlTypesSchemaImporterSmallMoney";
|
||||
internal const string SqlTypesSchemaImporterUniqueIdentifier = "SqlTypesSchemaImporterUniqueIdentifier";
|
||||
internal const string Type = "type";
|
||||
internal const string Mode = "mode";
|
||||
internal const string CheckDeserializeAdvances = "checkDeserializeAdvances";
|
||||
internal const string TempFilesLocation = "tempFilesLocation";
|
||||
internal const string UseLegacySerializerGeneration = "useLegacySerializerGeneration";
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="DateTimeSerializationSection.cs" company="Microsoft Corporation">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
// <owner current="true" primary="true">[....]</owner>
|
||||
//------------------------------------------------------------------------------
|
||||
#if CONFIGURATION_DEP
|
||||
namespace System.Xml.Serialization.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
|
||||
public sealed class DateTimeSerializationSection : ConfigurationSection
|
||||
{
|
||||
public enum DateTimeSerializationMode
|
||||
{
|
||||
Default = 0,
|
||||
Roundtrip = 1,
|
||||
Local = 2,
|
||||
}
|
||||
|
||||
public DateTimeSerializationSection()
|
||||
{
|
||||
this.properties.Add(this.mode);
|
||||
}
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.Mode, DefaultValue=DateTimeSerializationMode.Roundtrip)]
|
||||
public DateTimeSerializationMode Mode
|
||||
{
|
||||
get { return (DateTimeSerializationMode) this[this.mode]; }
|
||||
set { this[this.mode] = value; }
|
||||
}
|
||||
|
||||
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
|
||||
|
||||
// Supply a type converter, even though it's a plain type converter, to get around ConfigurationProperty's internal
|
||||
// Enum conversion routine. The internal one is case-sensitive, we want this to be case-insensitive.
|
||||
readonly ConfigurationProperty mode =
|
||||
new ConfigurationProperty(ConfigurationStrings.Mode, typeof(DateTimeSerializationMode), DateTimeSerializationMode.Roundtrip,
|
||||
new EnumConverter(typeof(DateTimeSerializationMode)), null, ConfigurationPropertyOptions.None);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,129 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="SchemaImporterExtensionElement.cs" company="Microsoft Corporation">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
// <owner current="true" primary="true">[....]</owner>
|
||||
//------------------------------------------------------------------------------
|
||||
#if CONFIGURATION_DEP
|
||||
namespace System.Xml.Serialization.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Security.Permissions;
|
||||
|
||||
public sealed class SchemaImporterExtensionElement : ConfigurationElement
|
||||
{
|
||||
public SchemaImporterExtensionElement()
|
||||
{
|
||||
this.properties.Add(this.name);
|
||||
this.properties.Add(this.type);
|
||||
}
|
||||
|
||||
public SchemaImporterExtensionElement(string name, string type) : this()
|
||||
{
|
||||
this.Name = name;
|
||||
this[this.type] = new TypeAndName(type);
|
||||
}
|
||||
|
||||
public SchemaImporterExtensionElement(string name, Type type) : this()
|
||||
{
|
||||
this.Name = name;
|
||||
this.Type = type;
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.Name, IsRequired=true, IsKey = true)]
|
||||
public string Name
|
||||
{
|
||||
get { return (string)this[this.name]; }
|
||||
set { this[this.name] = value; }
|
||||
}
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.Type, IsRequired=true, IsKey = false)]
|
||||
[TypeConverter(typeof(TypeTypeConverter))]
|
||||
public Type Type
|
||||
{
|
||||
get { return ((TypeAndName) this[this.type]).type; }
|
||||
set { this[this.type] = new TypeAndName(value); }
|
||||
}
|
||||
|
||||
internal string Key
|
||||
{
|
||||
get { return this.Name; }
|
||||
}
|
||||
|
||||
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
|
||||
|
||||
readonly ConfigurationProperty name =
|
||||
new ConfigurationProperty(ConfigurationStrings.Name, typeof(string), null,
|
||||
ConfigurationPropertyOptions.IsKey);
|
||||
|
||||
readonly ConfigurationProperty type =
|
||||
new ConfigurationProperty(ConfigurationStrings.Type, typeof(Type), null,
|
||||
new TypeTypeConverter(), null, ConfigurationPropertyOptions.IsRequired);
|
||||
|
||||
class TypeAndName
|
||||
{
|
||||
public TypeAndName(string name)
|
||||
{
|
||||
this.type = Type.GetType(name, true, true);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public TypeAndName(Type type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return type.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object comparand)
|
||||
{
|
||||
return type.Equals(((TypeAndName) comparand).type);
|
||||
}
|
||||
|
||||
public readonly Type type;
|
||||
public readonly string name;
|
||||
}
|
||||
|
||||
class TypeTypeConverter : TypeConverter {
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
|
||||
if (sourceType == typeof(string)) {
|
||||
return true;
|
||||
}
|
||||
return base.CanConvertFrom(context, sourceType);
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
|
||||
if (value is string) {
|
||||
return new TypeAndName((string) value);
|
||||
}
|
||||
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
|
||||
if (destinationType == typeof(string)) {
|
||||
TypeAndName castedValue = (TypeAndName) value;
|
||||
return castedValue.name == null ? castedValue.type.AssemblyQualifiedName : castedValue.name;
|
||||
}
|
||||
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,98 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="SchemaImporterExtensionElementCollection.cs" company="Microsoft Corporation">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
// <owner current="true" primary="true">[....]</owner>
|
||||
//------------------------------------------------------------------------------
|
||||
#if CONFIGURATION_DEP
|
||||
namespace System.Xml.Serialization.Configuration
|
||||
{
|
||||
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Security.Permissions;
|
||||
|
||||
[ConfigurationCollection(typeof(SchemaImporterExtensionElement))]
|
||||
public sealed class SchemaImporterExtensionElementCollection : ConfigurationElementCollection
|
||||
{
|
||||
public SchemaImporterExtensionElementCollection()
|
||||
{
|
||||
}
|
||||
|
||||
public SchemaImporterExtensionElement this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return (SchemaImporterExtensionElement)BaseGet(index);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (BaseGet(index) != null)
|
||||
{
|
||||
BaseRemoveAt(index);
|
||||
}
|
||||
BaseAdd(index,value);
|
||||
}
|
||||
}
|
||||
|
||||
public new SchemaImporterExtensionElement this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
return (SchemaImporterExtensionElement)BaseGet(name);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (BaseGet(name) != null)
|
||||
{
|
||||
BaseRemove(name);
|
||||
}
|
||||
BaseAdd(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(SchemaImporterExtensionElement element)
|
||||
{
|
||||
BaseAdd(element);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
BaseClear();
|
||||
}
|
||||
|
||||
protected override ConfigurationElement CreateNewElement()
|
||||
{
|
||||
return new SchemaImporterExtensionElement();
|
||||
}
|
||||
|
||||
protected override Object GetElementKey(ConfigurationElement element)
|
||||
{
|
||||
return ((SchemaImporterExtensionElement)element).Key;
|
||||
}
|
||||
|
||||
public int IndexOf(SchemaImporterExtensionElement element)
|
||||
{
|
||||
return BaseIndexOf(element);
|
||||
}
|
||||
|
||||
public void Remove(SchemaImporterExtensionElement element)
|
||||
{
|
||||
BaseRemove(element.Key);
|
||||
}
|
||||
|
||||
public void Remove(string name)
|
||||
{
|
||||
BaseRemove(name);
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
BaseRemoveAt(index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@@ -0,0 +1,108 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="SchemaImporterExtensionsSection.cs" company="Microsoft Corporation">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
// <owner current="true" primary="true">[....]</owner>
|
||||
//------------------------------------------------------------------------------
|
||||
#if CONFIGURATION_DEP
|
||||
namespace System.Xml.Serialization.Configuration
|
||||
{
|
||||
using System.Configuration;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Xml.Serialization.Advanced;
|
||||
|
||||
public sealed class SchemaImporterExtensionsSection : ConfigurationSection
|
||||
{
|
||||
public SchemaImporterExtensionsSection()
|
||||
{
|
||||
this.properties.Add(this.schemaImporterExtensions);
|
||||
}
|
||||
|
||||
private static string GetSqlTypeSchemaImporter(string typeName) {
|
||||
return "System.Data.SqlTypes." + typeName + ", " + AssemblyRef.SystemData;
|
||||
}
|
||||
|
||||
protected override void InitializeDefault()
|
||||
{
|
||||
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterChar, GetSqlTypeSchemaImporter("TypeCharSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterNChar, GetSqlTypeSchemaImporter("TypeNCharSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterVarChar, GetSqlTypeSchemaImporter("TypeVarCharSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterNVarChar, GetSqlTypeSchemaImporter("TypeNVarCharSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterText, GetSqlTypeSchemaImporter("TypeTextSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterNText, GetSqlTypeSchemaImporter("TypeNTextSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterVarBinary, GetSqlTypeSchemaImporter("TypeVarBinarySchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterBinary, GetSqlTypeSchemaImporter("TypeBinarySchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterImage, GetSqlTypeSchemaImporter("TypeVarImageSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterDecimal, GetSqlTypeSchemaImporter("TypeDecimalSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterNumeric, GetSqlTypeSchemaImporter("TypeNumericSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterBigInt, GetSqlTypeSchemaImporter("TypeBigIntSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterInt, GetSqlTypeSchemaImporter("TypeIntSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterSmallInt, GetSqlTypeSchemaImporter("TypeSmallIntSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterTinyInt, GetSqlTypeSchemaImporter("TypeTinyIntSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterBit, GetSqlTypeSchemaImporter("TypeBitSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterFloat, GetSqlTypeSchemaImporter("TypeFloatSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterReal, GetSqlTypeSchemaImporter("TypeRealSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterDateTime, GetSqlTypeSchemaImporter("TypeDateTimeSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterSmallDateTime, GetSqlTypeSchemaImporter("TypeSmallDateTimeSchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterMoney, GetSqlTypeSchemaImporter("TypeMoneySchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterSmallMoney, GetSqlTypeSchemaImporter("TypeSmallMoneySchemaImporterExtension")));
|
||||
this.SchemaImporterExtensions.Add(
|
||||
new SchemaImporterExtensionElement(ConfigurationStrings.SqlTypesSchemaImporterUniqueIdentifier, GetSqlTypeSchemaImporter("TypeUniqueIdentifierSchemaImporterExtension")));
|
||||
}
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties
|
||||
{
|
||||
get { return this.properties; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("", IsDefaultCollection = true)]
|
||||
public SchemaImporterExtensionElementCollection SchemaImporterExtensions
|
||||
{
|
||||
get { return (SchemaImporterExtensionElementCollection)this[this.schemaImporterExtensions]; }
|
||||
}
|
||||
|
||||
internal SchemaImporterExtensionCollection SchemaImporterExtensionsInternal {
|
||||
get {
|
||||
SchemaImporterExtensionCollection extensions = new SchemaImporterExtensionCollection();
|
||||
foreach(SchemaImporterExtensionElement elem in this.SchemaImporterExtensions) {
|
||||
extensions.Add(elem.Name, elem.Type);
|
||||
}
|
||||
|
||||
return extensions;
|
||||
}
|
||||
}
|
||||
|
||||
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
|
||||
|
||||
readonly ConfigurationProperty schemaImporterExtensions =
|
||||
new ConfigurationProperty(null, typeof(SchemaImporterExtensionElementCollection), null,
|
||||
ConfigurationPropertyOptions.IsDefaultCollection);
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,38 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="SerializationSectionGroup.cs" company="Microsoft Corporation">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
// <owner current="true" primary="true">[....]</owner>
|
||||
//------------------------------------------------------------------------------
|
||||
#if CONFIGURATION_DEP
|
||||
namespace System.Xml.Serialization.Configuration
|
||||
{
|
||||
using System.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for SerializationSectionGroup.
|
||||
/// </summary>
|
||||
public sealed class SerializationSectionGroup : ConfigurationSectionGroup
|
||||
{
|
||||
public SerializationSectionGroup() {}
|
||||
|
||||
// public properties
|
||||
[ConfigurationProperty(ConfigurationStrings.SchemaImporterExtensionsSectionName)]
|
||||
public SchemaImporterExtensionsSection SchemaImporterExtensions
|
||||
{
|
||||
get { return (SchemaImporterExtensionsSection)Sections[ConfigurationStrings.SchemaImporterExtensionsSectionName]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.DateTimeSerializationSectionName)]
|
||||
public DateTimeSerializationSection DateTimeSerialization
|
||||
{
|
||||
get { return (DateTimeSerializationSection)Sections[ConfigurationStrings.DateTimeSerializationSectionName]; }
|
||||
}
|
||||
|
||||
public XmlSerializerSection XmlSerializer
|
||||
{
|
||||
get { return (XmlSerializerSection)Sections[ConfigurationStrings.XmlSerializerSectionName]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,100 @@
|
||||
#if CONFIGURATION_DEP
|
||||
namespace System.Xml.Serialization.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Configuration;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
|
||||
public sealed class XmlSerializerSection : ConfigurationSection
|
||||
{
|
||||
public XmlSerializerSection()
|
||||
{
|
||||
this.properties.Add(this.checkDeserializeAdvances);
|
||||
this.properties.Add(this.tempFilesLocation);
|
||||
this.properties.Add(this.useLegacySerializerGeneration);
|
||||
}
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.CheckDeserializeAdvances, DefaultValue = false)]
|
||||
public bool CheckDeserializeAdvances
|
||||
{
|
||||
get { return (bool)this[this.checkDeserializeAdvances]; }
|
||||
set { this[this.checkDeserializeAdvances] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.TempFilesLocation, DefaultValue = null)]
|
||||
public string TempFilesLocation
|
||||
{
|
||||
get { return (string)this[this.tempFilesLocation]; }
|
||||
set { this[this.tempFilesLocation] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(ConfigurationStrings.UseLegacySerializerGeneration, DefaultValue = false)]
|
||||
public bool UseLegacySerializerGeneration
|
||||
{
|
||||
get { return (bool)this[this.useLegacySerializerGeneration]; }
|
||||
set { this[this.useLegacySerializerGeneration] = value; }
|
||||
}
|
||||
|
||||
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
|
||||
|
||||
// Supply a type converter, even though it's a plain type converter, to get around ConfigurationProperty's internal
|
||||
// Enum conversion routine. The internal one is case-sensitive, we want this to be case-insensitive.
|
||||
readonly ConfigurationProperty checkDeserializeAdvances =
|
||||
new ConfigurationProperty(ConfigurationStrings.CheckDeserializeAdvances, typeof(bool), false,
|
||||
ConfigurationPropertyOptions.None);
|
||||
|
||||
readonly ConfigurationProperty tempFilesLocation =
|
||||
new ConfigurationProperty(ConfigurationStrings.TempFilesLocation, typeof(string), null, null,
|
||||
new RootedPathValidator(),
|
||||
ConfigurationPropertyOptions.None);
|
||||
|
||||
readonly ConfigurationProperty useLegacySerializerGeneration =
|
||||
new ConfigurationProperty(ConfigurationStrings.UseLegacySerializerGeneration, typeof(bool), false,
|
||||
ConfigurationPropertyOptions.None);
|
||||
}
|
||||
|
||||
|
||||
public class RootedPathValidator : ConfigurationValidatorBase
|
||||
{
|
||||
public override bool CanValidate(Type type)
|
||||
{
|
||||
return (type == typeof(string));
|
||||
}
|
||||
|
||||
public override void Validate(object value)
|
||||
{
|
||||
string tempDirectory = value as string;
|
||||
if (string.IsNullOrEmpty(tempDirectory))
|
||||
return;
|
||||
tempDirectory = tempDirectory.Trim();
|
||||
if (string.IsNullOrEmpty(tempDirectory))
|
||||
return;
|
||||
if (!Path.IsPathRooted(tempDirectory))
|
||||
{
|
||||
// Make sure the path is not relative (VSWhidbey 260075)
|
||||
throw new ConfigurationErrorsException();
|
||||
}
|
||||
char firstChar = tempDirectory[0];
|
||||
if (firstChar == Path.DirectorySeparatorChar || firstChar == Path.AltDirectorySeparatorChar)
|
||||
{
|
||||
// Make sure the path is explicitly rooted
|
||||
throw new ConfigurationErrorsException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user