diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2009-12-11 12:47:44 +0300 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2009-12-11 12:47:44 +0300 |
commit | 50dd72781128da807c601b4c398bd154cd0a5067 (patch) | |
tree | 86152a8e1ddc3aea4200da13dc8c43d86ab258f0 /mcs/class/System.ServiceModel.Routing | |
parent | 08e0425bd20814e78d1f5d4cdc9186a71d971330 (diff) |
2009-12-11 Atsushi Enomoto <atsushi@ximian.com>
* RoutingSection.cs : sorted out most of the configuration stuff.
* FilterElementCollection.cs : added missing indexer.
svn path=/trunk/mcs/; revision=148096
Diffstat (limited to 'mcs/class/System.ServiceModel.Routing')
3 files changed, 70 insertions, 12 deletions
diff --git a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/ChangeLog b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/ChangeLog index 5eb3080b371..4579c955b56 100644 --- a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/ChangeLog +++ b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/ChangeLog @@ -1,3 +1,8 @@ +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 diff --git a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/FilterElementCollection.cs b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/FilterElementCollection.cs index 0834019a69d..a87402bcbec 100644 --- a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/FilterElementCollection.cs +++ b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/FilterElementCollection.cs @@ -2,6 +2,7 @@ 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; @@ -33,6 +34,15 @@ namespace System.ServiceModel.Routing.Configuration 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 override bool IsReadOnly () { return base.IsReadOnly (); diff --git a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/RoutingSection.cs b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/RoutingSection.cs index 66811f85268..68cde00fa00 100644 --- a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/RoutingSection.cs +++ b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/RoutingSection.cs @@ -11,31 +11,74 @@ using System.ServiceModel.Dispatcher; namespace System.ServiceModel.Routing.Configuration { + static class RoutingConfigurationExtension + { + public static ServiceEndpoint CreateEndpoint (this ChannelEndpointElement el) + { + // FIXME: implement + throw new NotImplementedException (); + } + + 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 ServiceModelSectionGroup wcfRootSection = ConfigurationManager.GetSection ("system.serviceModel") as ServiceModelSectionGroup; + + static ServiceEndpoint CreateServiceEndpoint (string name) + { + // FIXME: might be service endpoints. + var endpoints = wcfRootSection.Client.Endpoints; + return ((ChannelEndpointElement) endpoints [name]).CreateEndpoint (); + } + [MonoTODO] public static MessageFilterTable<IEnumerable<ServiceEndpoint>> CreateFilterTable (string name) { - throw new NotImplementedException (); - /* - // FIXME: I feel messed. var sec = (RoutingSection) ConfigurationManager.GetSection ("system.serviceModel/routing"); - var endpoints = ((ServiceModelSectionGroup) ConfigurationManager.GetSection ("system.serviceModel")).Client.Endpoints; + + var filters = new Dictionary<string,MessageFilter> (); var table = new MessageFilterTable<IEnumerable<ServiceEndpoint>> (); var ftec = (FilterTableEntryCollection) sec.FilterTables [name]; foreach (FilterTableEntryElement fte in ftec) { - var filter = table.Keys.FirstOrDefault (f => ((EndpointNameMessageFilter) f).Name == fte.FilterName); - if (filter == null) { - filter = new EndpointNameMessageFilter (fte.EndpointName); - table.Add (filter, new List<ServiceEndpoint> ()); + MessageFilter filter; + if (filters.TryGetValue (fte.FilterName, out filter)) { + var filterElement = (FilterElement) sec.Filters [fte.FilterName]; + filter = filterElement.CreateFilter (sec); } - var list = table [filter]; + 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]; - foreach (var bee in bec) - list.Add (endpoints [bee.EndpointName]); + foreach (BackupEndpointElement bee in bec) + list.Add (CreateServiceEndpoint (bee.EndpointName)); } return table; - */ } public RoutingSection () |