Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@ -0,0 +1,56 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Activation.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.Format(CultureInfo.InvariantCulture, @"{0}/{1}", ConfigurationStrings.SectionGroupName, sectionName);
}
static internal string DiagnosticSectionPath
{
get { return ConfigurationStrings.GetSectionPath(ConfigurationStrings.DiagnosticSectionName); }
}
static internal string NetTcpSectionPath
{
get { return ConfigurationStrings.GetSectionPath(ConfigurationStrings.NetTcpSectionName); }
}
static internal string NetPipeSectionPath
{
get { return ConfigurationStrings.GetSectionPath(ConfigurationStrings.NetPipeSectionName); }
}
internal const string SectionGroupName = "system.serviceModel.activation";
// Sid for the built-in group IIS_IUSRS for IIS7
internal const string IIS_IUSRSSid = "S-1-5-32-568";
internal const string DiagnosticSectionName = "diagnostics";
internal const string NetTcpSectionName = "net.tcp";
internal const string NetPipeSectionName = "net.pipe";
internal const string AllowAccounts = "allowAccounts";
internal const string Enabled = "enabled";
internal const string ListenBacklog = "listenBacklog";
internal const string MaxPendingAccepts = "maxPendingAccepts";
internal const string MaxPendingConnections = "maxPendingConnections";
internal const string PerformanceCountersEnabled = "performanceCountersEnabled";
internal const string ReceiveTimeout = "receiveTimeout";
internal const string SecurityIdentifier = "securityIdentifier";
internal const string TeredoEnabled = "teredoEnabled";
internal const string TimeSpanOneTick = "00:00:00.0000001";
internal const string TimeSpanZero = "00:00:00";
}
}

View File

@ -0,0 +1,37 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Activation.Configuration
{
using System;
using System.Configuration;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
public sealed partial class DiagnosticSection : ConfigurationSection
{
public DiagnosticSection()
: base()
{
}
static internal DiagnosticSection GetSection()
{
DiagnosticSection retval = (DiagnosticSection)ConfigurationManager.GetSection(ConfigurationStrings.DiagnosticSectionPath);
if (retval == null)
{
retval = new DiagnosticSection();
}
return retval;
}
[ConfigurationProperty(ConfigurationStrings.PerformanceCountersEnabled, DefaultValue = ListenerConstants.DefaultPerformanceCountersEnabled)]
public bool PerformanceCountersEnabled
{
get { return (bool)base[ConfigurationStrings.PerformanceCountersEnabled]; }
set { base[ConfigurationStrings.PerformanceCountersEnabled] = value; }
}
}
}

View File

@ -0,0 +1,82 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Activation.Configuration
{
using System;
using System.Configuration;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
public sealed partial class NetPipeSection : ConfigurationSection
{
PropertyInformationCollection propertyInfo;
public NetPipeSection()
: base()
{
propertyInfo = this.ElementInformation.Properties;
}
[ConfigurationProperty(ConfigurationStrings.AllowAccounts)]
public SecurityIdentifierElementCollection AllowAccounts
{
get { return (SecurityIdentifierElementCollection)base[ConfigurationStrings.AllowAccounts]; }
}
static internal NetPipeSection GetSection()
{
NetPipeSection retval = (NetPipeSection)ConfigurationManager.GetSection(ConfigurationStrings.NetPipeSectionPath);
if (retval == null)
{
retval = new NetPipeSection();
}
return retval;
}
protected override void InitializeDefault()
{
this.AllowAccounts.SetDefaultIdentifiers();
}
[ConfigurationProperty(ConfigurationStrings.MaxPendingConnections, DefaultValue = ListenerConstants.DefaultMaxPendingConnections)]
[IntegerValidator(MinValue = 0)]
public int MaxPendingConnections
{
get { return (int)base[ConfigurationStrings.MaxPendingConnections]; }
set { base[ConfigurationStrings.MaxPendingConnections] = value; }
}
[ConfigurationProperty(ConfigurationStrings.MaxPendingAccepts, DefaultValue = ListenerConstants.DefaultMaxPendingAccepts)]
[IntegerValidator(MinValue = 0)]
public int MaxPendingAccepts
{
get
{
int maxPendingAccepts = (int)base[ConfigurationStrings.MaxPendingAccepts];
if (maxPendingAccepts != ListenerConstants.DefaultMaxPendingAccepts)
{
// if the user changed the default, return user's value
return maxPendingAccepts;
}
else
{
// otherwise return 2 * transport default, since SMSvcHost defaults are global
return 2 * ConnectionOrientedTransportDefaults.GetMaxPendingAccepts();
}
}
set { base[ConfigurationStrings.MaxPendingAccepts] = value; }
}
[ConfigurationProperty(ConfigurationStrings.ReceiveTimeout, DefaultValue = ListenerConstants.DefaultReceiveTimeoutString)]
[System.ComponentModel.TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[System.ServiceModel.Configuration.ServiceModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanZero)]
public TimeSpan ReceiveTimeout
{
get { return (TimeSpan)base[ConfigurationStrings.ReceiveTimeout]; }
set { base[ConfigurationStrings.ReceiveTimeout] = value; }
}
}
}

View File

@ -0,0 +1,111 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Activation.Configuration
{
using System;
using System.Configuration;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
public sealed partial class NetTcpSection : ConfigurationSection
{
PropertyInformationCollection propertyInfo;
public NetTcpSection()
: base()
{
propertyInfo = this.ElementInformation.Properties;
}
[ConfigurationProperty(ConfigurationStrings.AllowAccounts)]
public SecurityIdentifierElementCollection AllowAccounts
{
get { return (SecurityIdentifierElementCollection)base[ConfigurationStrings.AllowAccounts]; }
}
static internal NetTcpSection GetSection()
{
NetTcpSection retval = (NetTcpSection)ConfigurationManager.GetSection(ConfigurationStrings.NetTcpSectionPath);
if (retval == null)
{
retval = new NetTcpSection();
}
return retval;
}
protected override void InitializeDefault()
{
this.AllowAccounts.SetDefaultIdentifiers();
}
[ConfigurationProperty(ConfigurationStrings.ListenBacklog, DefaultValue = ListenerConstants.DefaultListenBacklog)]
[IntegerValidator(MinValue = 0)]
public int ListenBacklog
{
get
{
int listenBacklog = (int)base[ConfigurationStrings.ListenBacklog];
if (listenBacklog != ListenerConstants.DefaultListenBacklog)
{
// if the user changed the default, return user's value
return listenBacklog;
}
else
{
// otherwise return the transport default
return TcpTransportDefaults.GetListenBacklog();
}
}
set { base[ConfigurationStrings.ListenBacklog] = value; }
}
[ConfigurationProperty(ConfigurationStrings.MaxPendingConnections, DefaultValue = ListenerConstants.DefaultMaxPendingConnections)]
[IntegerValidator(MinValue = 0)]
public int MaxPendingConnections
{
get { return (int)base[ConfigurationStrings.MaxPendingConnections]; }
set { base[ConfigurationStrings.MaxPendingConnections] = value; }
}
[ConfigurationProperty(ConfigurationStrings.MaxPendingAccepts, DefaultValue = ListenerConstants.DefaultMaxPendingAccepts)]
[IntegerValidator(MinValue = 0)]
public int MaxPendingAccepts
{
get
{
int maxPendingAccepts = (int)base[ConfigurationStrings.MaxPendingAccepts];
if (maxPendingAccepts != ListenerConstants.DefaultMaxPendingAccepts)
{
// if the user changed the default, return user's value
return maxPendingAccepts;
}
else
{
// otherwise return 2 * transport default, since SMSvcHost defaults are global
return 2 * ConnectionOrientedTransportDefaults.GetMaxPendingAccepts();
}
}
set { base[ConfigurationStrings.MaxPendingAccepts] = value; }
}
[ConfigurationProperty(ConfigurationStrings.ReceiveTimeout, DefaultValue = ListenerConstants.DefaultReceiveTimeoutString)]
[System.ComponentModel.TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[System.ServiceModel.Configuration.ServiceModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanZero)]
public TimeSpan ReceiveTimeout
{
get { return (TimeSpan)base[ConfigurationStrings.ReceiveTimeout]; }
set { base[ConfigurationStrings.ReceiveTimeout] = value; }
}
[ConfigurationProperty(ConfigurationStrings.TeredoEnabled, DefaultValue = ListenerConstants.DefaultTeredoEnabled)]
public bool TeredoEnabled
{
get { return (bool)base[ConfigurationStrings.TeredoEnabled]; }
set { base[ConfigurationStrings.TeredoEnabled] = value; }
}
}
}

View File

@ -0,0 +1,58 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Activation.Configuration
{
using System;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Runtime;
using System.Security.Principal;
class SecurityIdentifierConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (typeof(string) == sourceType)
{
return true;
}
return base.CanConvertFrom(context, sourceType);
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (typeof(InstanceDescriptor) == destinationType)
{
return true;
}
return base.CanConvertTo(context, destinationType);
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
Fx.Assert(this.CanConvertFrom(context, value.GetType()), "");
if (value is string)
{
return new SecurityIdentifier((string)value);
}
return base.ConvertFrom(context, culture, value);
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
Fx.Assert(this.CanConvertTo(context, destinationType), "");
if (destinationType == typeof(string) && value is SecurityIdentifier)
{
SecurityIdentifier sid = (SecurityIdentifier)value;
return sid.Value;
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
}

View File

@ -0,0 +1,33 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Activation.Configuration
{
using System;
using System.ComponentModel;
using System.Configuration;
using System.Security.Principal;
public sealed partial class SecurityIdentifierElement : ConfigurationElement
{
public SecurityIdentifierElement()
: base()
{
}
public SecurityIdentifierElement(SecurityIdentifier sid)
: this()
{
this.SecurityIdentifier = sid;
}
[ConfigurationProperty(ConfigurationStrings.SecurityIdentifier, DefaultValue = null, Options = ConfigurationPropertyOptions.IsKey)]
[TypeConverter(typeof(SecurityIdentifierConverter))]
public SecurityIdentifier SecurityIdentifier
{
get { return (SecurityIdentifier)base[ConfigurationStrings.SecurityIdentifier]; }
set { base[ConfigurationStrings.SecurityIdentifier] = value; }
}
}
}

View File

@ -0,0 +1,48 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Activation.Configuration
{
using System;
using System.Collections;
using System.Configuration;
using System.Globalization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Configuration;
using System.ServiceModel.Channels;
using System.Security.Principal;
[ConfigurationCollection(typeof(SecurityIdentifierElement))]
public sealed class SecurityIdentifierElementCollection : ServiceModelConfigurationElementCollection<SecurityIdentifierElement>
{
public SecurityIdentifierElementCollection() : base() { }
protected override Object GetElementKey(ConfigurationElement element)
{
if (element == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
}
SecurityIdentifierElement configElementKey = (SecurityIdentifierElement)element;
return configElementKey.SecurityIdentifier.Value;
}
internal void SetDefaultIdentifiers()
{
if (Iis7Helper.IisVersion >= 7)
{
this.Add(new SecurityIdentifierElement(new SecurityIdentifier(ConfigurationStrings.IIS_IUSRSSid)));
}
this.Add(new SecurityIdentifierElement(new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null)));
this.Add(new SecurityIdentifierElement(new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null)));
this.Add(new SecurityIdentifierElement(new SecurityIdentifier(WellKnownSidType.LocalServiceSid, null)));
this.Add(new SecurityIdentifierElement(new SecurityIdentifier(WellKnownSidType.NetworkServiceSid, null)));
}
}
}

View File

@ -0,0 +1,39 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Activation.Configuration
{
using System;
using System.Configuration;
public sealed class ServiceModelActivationSectionGroup : ConfigurationSectionGroup
{
public DiagnosticSection Diagnostics
{
get { return (DiagnosticSection)this.Sections[ConfigurationStrings.DiagnosticSectionName]; }
}
static public ServiceModelActivationSectionGroup GetSectionGroup(Configuration config)
{
if (config == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("config");
}
#pragma warning suppress 56506 // [....], Configuration.SectionGroups cannot be null
return (ServiceModelActivationSectionGroup)config.SectionGroups[ConfigurationStrings.SectionGroupName];
}
public NetPipeSection NetPipe
{
get { return (NetPipeSection)this.Sections[ConfigurationStrings.NetPipeSectionName]; }
}
public NetTcpSection NetTcp
{
get { return (NetTcpSection)this.Sections[ConfigurationStrings.NetTcpSectionName]; }
}
}
}