Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace System.ServiceModel.Routing.Configuration
{
[ConfigurationCollection (typeof (BackupEndpointElement))]
public class BackupEndpointCollection : ConfigurationElementCollection
{
[ConfigurationProperty ("name", DefaultValue = null, Options = ConfigurationPropertyOptions.IsRequired)]
public string Name {
get { return (string) base ["name"]; }
set { base ["name"] = value; }
}
public BackupEndpointCollection ()
{
}
public void Add (BackupEndpointElement element)
{
BaseAdd (element);
}
public void Clear ()
{
BaseClear ();
}
protected override ConfigurationElement CreateNewElement ()
{
return new BackupEndpointElement ();
}
protected override object GetElementKey (ConfigurationElement element)
{
return ((BackupEndpointElement) element).EndpointName;
}
public void Remove (BackupEndpointElement element)
{
BaseRemove (element);
}
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace System.ServiceModel.Routing.Configuration
{
public class BackupEndpointElement : ConfigurationElement
{
[ConfigurationProperty ("endpointName", DefaultValue = null, Options = ConfigurationPropertyOptions.IsRequired)]
public string EndpointName {
get { return (string) base ["endpointName"]; }
set { base ["endpointName"] = value; }
}
}
}

View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace System.ServiceModel.Routing.Configuration
{
[ConfigurationCollection (typeof (BackupEndpointCollection), AddItemName = "backupList")]
public class BackupListCollection : ConfigurationElementCollection
{
public void Add (BackupEndpointCollection element)
{
BaseAdd (element);
}
public void Clear ()
{
BaseClear ();
}
protected override ConfigurationElement CreateNewElement ()
{
return new BackupEndpointElement ();
}
protected override Object GetElementKey (ConfigurationElement element)
{
return ((BackupEndpointElement) element).EndpointName;
}
public void Remove (BackupEndpointCollection element)
{
BaseRemove (element);
}
public new BackupEndpointCollection this [string name] {
get {
foreach (BackupEndpointCollection c in this)
if (c.Name == name)
return c;
return null;
}
}
}
}

View File

@ -0,0 +1,40 @@
2010-06-03 Atsushi Enomoto <atsushi@ximian.com>
* BackupEndpointCollection.cs
BackupEndpointElement.cs
BackupListCollection.cs
FilterElement.cs
FilterElementCollection.cs
FilterTableEntryCollection.cs
FilterTableEntryElement.cs
NamespaceElement.cs
NamespaceElementCollection.cs
RoutingExtensionElement.cs
RoutingSection.cs
SoapProcessingExtensionElement.cs : implement to get working.
2010-03-02 Raja R Harinath <harinath@hurrynot.org>
* BackupListCollection.cs, FilterTableCollection.cs: Add indexer.
2009-12-11 Atsushi Enomoto <atsushi@ximian.com>
* RoutingSection.cs : sorted out most of the configuration stuff.
* FilterElementCollection.cs : added missing indexer.
2009-12-10 Atsushi Enomoto <atsushi@ximian.com>
* BackupEndpointCollection.cs
BackupEndpointElement.cs
BackupListCollection.cs
FilterElement.cs
FilterElementCollection.cs
FilterTableCollection.cs
FilterTableEntryCollection.cs
FilterTableEntryElement.cs
FilterType.cs
NamespaceElement.cs
NamespaceElementCollection.cs
RoutingExtensionElement.cs
RoutingSection.cs
SoapProcessingExtensionElement.cs : initial checkin.

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace System.ServiceModel.Routing.Configuration
{
public class FilterElement : ConfigurationElement
{
[ConfigurationProperty ("customType", DefaultValue = null, Options = ConfigurationPropertyOptions.None)]
public string CustomType {
get { return (string) base ["customType"]; }
set { base ["customType"] = value; }
}
[ConfigurationProperty ("filter1", DefaultValue = null, Options = ConfigurationPropertyOptions.None)]
public string Filter1 {
get { return (string) base ["filter1"]; }
set { base ["filter1"] = value; }
}
[ConfigurationProperty ("filter2", DefaultValue = null, Options = ConfigurationPropertyOptions.None)]
public string Filter2 {
get { return (string) base ["filter2"]; }
set { base ["filter2"] = value; }
}
[ConfigurationProperty ("filterData", DefaultValue = null, Options = ConfigurationPropertyOptions.None)]
public string FilterData {
get { return (string) base ["filterData"]; }
set { base ["filterData"] = value; }
}
[ConfigurationProperty ("filterType", DefaultValue = null, Options = ConfigurationPropertyOptions.IsRequired)]
public FilterType FilterType {
get { return (FilterType) base ["filterType"]; }
set { base ["filterType"] = value; }
}
[ConfigurationProperty ("name", DefaultValue = null, Options = ConfigurationPropertyOptions.None | ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
public string Name {
get { return (string) base ["name"]; }
set { base ["name"] = value; }
}
}
}

View File

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace System.ServiceModel.Routing.Configuration
{
[ConfigurationCollection (typeof(FilterElement), AddItemName = "filter")]
public class FilterElementCollection : ConfigurationElementCollection
{
public void Add (FilterElement element)
{
BaseAdd (element);
}
public void Clear ()
{
BaseClear ();
}
protected override ConfigurationElement CreateNewElement ()
{
return new FilterElement ();
}
protected override object GetElementKey (ConfigurationElement element)
{
return ((FilterElement) element).Name;
}
public new FilterElement this [string name] {
get {
foreach (FilterElement fe in this)
if (fe.Name == name)
return fe;
return null;
}
}
public FilterElement this [int index] {
get { return (FilterElement) BaseGet (index); }
}
public override bool IsReadOnly ()
{
return base.IsReadOnly ();
}
public void Remove (FilterElement element)
{
BaseRemove (element);
}
}
}

View File

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace System.ServiceModel.Routing.Configuration
{
[ConfigurationCollection (typeof (FilterTableEntryCollection), AddItemName = "filterTable")]
public class FilterTableCollection : ConfigurationElementCollection
{
public void Add (FilterTableEntryCollection element)
{
BaseAdd (element);
}
public void Clear ()
{
BaseClear ();
}
protected override ConfigurationElement CreateNewElement ()
{
return new FilterTableEntryCollection ();
}
protected override object GetElementKey (ConfigurationElement element)
{
return ((FilterTableEntryCollection) element).Name;
}
public void Remove (FilterTableEntryCollection element)
{
BaseRemove (element);
}
public new FilterTableEntryCollection this [string name] {
get { return (FilterTableEntryCollection) BaseGet (name); }
}
}
}

View File

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace System.ServiceModel.Routing.Configuration
{
[ConfigurationCollection (typeof(FilterTableEntryElement))]
public class FilterTableEntryCollection : ConfigurationElementCollection
{
[ConfigurationProperty ("name", DefaultValue = null, Options = ConfigurationPropertyOptions.None | ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
public string Name {
get { return (string) base ["name"]; }
set { base ["name"] = value; }
}
public void Add (FilterTableEntryElement element)
{
BaseAdd (element);
}
public void Clear ()
{
BaseClear ();
}
protected override ConfigurationElement CreateNewElement ()
{
return new FilterTableEntryElement ();
}
protected override object GetElementKey (ConfigurationElement element)
{
return ((FilterTableEntryElement) element).EndpointName;
}
public void Remove (FilterTableEntryElement element)
{
BaseRemove (element);
}
}
}

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace System.ServiceModel.Routing.Configuration
{
public class FilterTableEntryElement : ConfigurationElement
{
[ConfigurationProperty ("backupList", DefaultValue = null, Options = ConfigurationPropertyOptions.None)]
public string BackupList {
get { return (string) base ["backupList"]; }
set { base ["backupList"] = value; }
}
[ConfigurationProperty ("endpointName", DefaultValue = null, Options = ConfigurationPropertyOptions.None | ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
public string EndpointName {
get { return (string) base ["endpointName"]; }
set { base ["endpointName"] = value; }
}
[ConfigurationProperty ("filterName", DefaultValue = null, Options = ConfigurationPropertyOptions.None | ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
public string FilterName {
get { return (string) base ["filterName"]; }
set { base ["filterName"] = value; }
}
[ConfigurationProperty ("priority", Options = ConfigurationPropertyOptions.None)]
public int Priority {
get { return (int) base ["priority"]; }
set { base ["priority"] = value; }
}
}
}

View File

@ -0,0 +1,14 @@
namespace System.ServiceModel.Routing.Configuration
{
public enum FilterType
{
Action,
EndpointAddress,
PrefixEndpointAddress,
And,
Custom,
EndpointName,
MatchAll,
XPath
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace System.ServiceModel.Routing.Configuration
{
public class NamespaceElement : ConfigurationElement
{
[ConfigurationProperty ("namespace", DefaultValue = null, Options = ConfigurationPropertyOptions.IsRequired)]
public string Namespace {
get { return (string) base ["namespace"]; }
set { base ["namespace"] = value; }
}
[ConfigurationProperty ("prefix", DefaultValue = null, Options = ConfigurationPropertyOptions.None | ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
public string Prefix {
get { return (string) base ["prefix"]; }
set { base ["prefix"] = value; }
}
}
}

View File

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace System.ServiceModel.Routing.Configuration
{
[ConfigurationCollection (typeof(NamespaceElement))]
public class NamespaceElementCollection : ConfigurationElementCollection
{
public void Add (NamespaceElement element)
{
BaseAdd (element);
}
public void Clear ()
{
BaseClear ();
}
protected override ConfigurationElement CreateNewElement ()
{
return new NamespaceElement ();
}
protected override object GetElementKey (ConfigurationElement element)
{
return ((NamespaceElement) element).Prefix;
}
public new NamespaceElement this [string name] {
get {
foreach (NamespaceElement ne in this)
if (ne.Namespace == name)
return ne;
return null;
}
}
public NamespaceElement this [int index] {
get { return (NamespaceElement) BaseGet (index); }
}
public override bool IsReadOnly ()
{
return base.IsReadOnly ();
}
public void Remove (NamespaceElement element)
{
BaseRemove (element);
}
}
}

View File

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace System.ServiceModel.Routing.Configuration
{
public sealed class RoutingExtensionElement : BehaviorExtensionElement
{
public override Type BehaviorType {
get { return typeof (RoutingExtension); }
}
[ConfigurationProperty ("filterTableName", DefaultValue = null)]
public string FilterTableName {
get { return (string) base ["filterTableName"]; }
set { base ["filterTableName"] = value; }
}
[ConfigurationProperty ("routeOnHeadersOnly", DefaultValue = true, Options = ConfigurationPropertyOptions.None)]
public bool RouteOnHeadersOnly {
get { return (bool) base ["routeOnHeadersOnly"]; }
set { base ["routeOnHeadersOnly"] = value; }
}
[ConfigurationProperty ("soapProcessingEnabled", DefaultValue = true)]
public bool SoapProcessingEnabled {
get { return (bool) base ["soapProcessingEnabled"]; }
set { base ["soapProcessingEnabled"] = value; }
}
protected internal override object CreateBehavior ()
{
var table = RoutingSection.CreateFilterTable (FilterTableName);
var cfg = new RoutingConfiguration (table, RouteOnHeadersOnly) { SoapProcessingEnabled = this.SoapProcessingEnabled };
return new RoutingBehavior (cfg);
}
}
}

View File

@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace System.ServiceModel.Routing.Configuration
{
static class RoutingConfigurationExtension
{
public static ServiceEndpoint CreateEndpoint (this ChannelEndpointElement el)
{
// depends on System.ServiceModel internals (by InternalVisibleTo).
// FIXME: is IRequestReplyRouter okay for every case?
return new ServiceEndpoint (ContractDescription.GetContract (typeof (IRequestReplyRouter)), ConfigUtil.CreateBinding (el.Binding, el.BindingConfiguration), new EndpointAddress (el.Address));
}
public static MessageFilter CreateFilter (this FilterElement el, RoutingSection sec)
{
switch (el.FilterType) {
case FilterType.Action:
return new ActionMessageFilter (el.FilterData);
case FilterType.EndpointAddress:
return new EndpointAddressMessageFilter (new EndpointAddress (el.FilterData), false);
case FilterType.PrefixEndpointAddress:
return new PrefixEndpointAddressMessageFilter (new EndpointAddress (el.FilterData), false);
case FilterType.And:
var fe1 = (FilterElement) sec.Filters [el.Filter1];
var fe2 = (FilterElement) sec.Filters [el.Filter2];
return new StrictAndMessageFilter (fe1.CreateFilter (sec), fe2.CreateFilter (sec));
case FilterType.Custom:
return (MessageFilter) Activator.CreateInstance (Type.GetType (el.CustomType));
case FilterType.EndpointName:
return new EndpointNameMessageFilter (el.FilterData);
case FilterType.MatchAll:
return new MatchAllMessageFilter ();
case FilterType.XPath:
return new XPathMessageFilter (el.FilterData);
default:
throw new ArgumentOutOfRangeException ("FilterType");
}
}
}
public class RoutingSection : ConfigurationSection
{
static ServiceEndpoint CreateServiceEndpoint (string name)
{
// FIXME: might be service endpoints.
var endpoints = ConfigUtil.ClientSection.Endpoints;
foreach (ChannelEndpointElement ep in endpoints)
if (ep.Name == name)
return ep.CreateEndpoint ();
throw new KeyNotFoundException (String.Format ("client endpoint '{0}' not found", name));
}
[MonoTODO]
public static MessageFilterTable<IEnumerable<ServiceEndpoint>> CreateFilterTable (string name)
{
var sec = (RoutingSection) ConfigurationManager.GetSection ("system.serviceModel/routing");
var table = new MessageFilterTable<IEnumerable<ServiceEndpoint>> ();
var ftec = (FilterTableEntryCollection) sec.FilterTables [name];
foreach (FilterTableEntryElement fte in ftec) {
var filterElement = (FilterElement) sec.Filters [fte.FilterName];
MessageFilter filter = filterElement.CreateFilter (sec);
table.Add (filter, new List<ServiceEndpoint> (), fte.Priority);
var list = (List<ServiceEndpoint>) table [filter];
list.Add (CreateServiceEndpoint (fte.EndpointName));
var bec = (BackupEndpointCollection) sec.BackupLists [fte.BackupList];
if (bec != null)
foreach (BackupEndpointElement bee in bec)
list.Add (CreateServiceEndpoint (bee.EndpointName));
}
return table;
}
public RoutingSection ()
{
//BackupLists = new BackupListCollection ();
//Filters = new FilterElementCollection ();
//FilterTables = new FilterTableCollection ();
//NamespaceTable = new NamespaceElementCollection ();
}
[ConfigurationProperty ("backupLists", Options = ConfigurationPropertyOptions.None)]
public BackupListCollection BackupLists {
get { return (BackupListCollection) base ["backupLists"]; }
private set { base ["backupLists"] = value; }
}
[ConfigurationProperty ("filters", Options = ConfigurationPropertyOptions.None)]
public FilterElementCollection Filters {
get { return (FilterElementCollection) base ["filters"]; }
private set { base ["filters"] = value; }
}
[ConfigurationProperty ("filterTables", Options = ConfigurationPropertyOptions.None)]
public FilterTableCollection FilterTables {
get { return (FilterTableCollection) base ["filterTables"]; }
private set { base ["filterTables"] = value; }
}
[ConfigurationProperty ("namespaceTable", Options = ConfigurationPropertyOptions.None)]
public NamespaceElementCollection NamespaceTable {
get { return (NamespaceElementCollection) base ["namespaceTable"]; }
private set { base ["namespaceTable"] = value; }
}
}
}

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace System.ServiceModel.Routing.Configuration
{
public class SoapProcessingExtensionElement : BehaviorExtensionElement
{
public override Type BehaviorType {
get { return typeof (SoapProcessingBehavior); }
}
[ConfigurationProperty ("processMessages", DefaultValue = true, Options = ConfigurationPropertyOptions.None)]
public bool ProcessMessages {
get { return (bool) base ["processMessages"]; }
set { base ["processMessages"] = value; }
}
protected internal override object CreateBehavior ()
{
return new SoapProcessingBehavior () { ProcessMessages = this.ProcessMessages };
}
}
}