diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2010-06-03 10:32:09 +0400 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2010-06-03 10:32:09 +0400 |
commit | 0e452537e75c9df0dca2349b0f048976a478e62f (patch) | |
tree | 848e6dd14bf69c9e1b5a8c4ad5189ed428821331 /mcs/class/System.ServiceModel.Routing | |
parent | f59b0d7eb6e22c43ca8f4c2ed9b66254f3e148ac (diff) |
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.
svn path=/trunk/mcs/; revision=158382
Diffstat (limited to 'mcs/class/System.ServiceModel.Routing')
13 files changed, 161 insertions, 54 deletions
diff --git a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/BackupEndpointCollection.cs b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/BackupEndpointCollection.cs index 01baedd46ea..32592d51ad4 100644 --- a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/BackupEndpointCollection.cs +++ b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/BackupEndpointCollection.cs @@ -13,6 +13,12 @@ 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 () { } @@ -22,6 +28,11 @@ namespace System.ServiceModel.Routing.Configuration BaseAdd (element); } + public void Clear () + { + BaseClear (); + } + protected override ConfigurationElement CreateNewElement () { return new BackupEndpointElement (); diff --git a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/BackupEndpointElement.cs b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/BackupEndpointElement.cs index a6bf14d130b..cec12175d81 100644 --- a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/BackupEndpointElement.cs +++ b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/BackupEndpointElement.cs @@ -13,6 +13,9 @@ namespace System.ServiceModel.Routing.Configuration public class BackupEndpointElement : ConfigurationElement { [ConfigurationProperty ("endpointName", DefaultValue = null, Options = ConfigurationPropertyOptions.IsRequired)] - public string EndpointName { get; set; } + public string EndpointName { + get { return (string) base ["endpointName"]; } + set { base ["endpointName"] = value; } + } } } diff --git a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/BackupListCollection.cs b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/BackupListCollection.cs index 1db6d8c87cb..5f25b8a09ee 100644 --- a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/BackupListCollection.cs +++ b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/BackupListCollection.cs @@ -18,6 +18,11 @@ namespace System.ServiceModel.Routing.Configuration BaseAdd (element); } + public void Clear () + { + BaseClear (); + } + protected override ConfigurationElement CreateNewElement () { return new BackupEndpointElement (); @@ -34,7 +39,12 @@ namespace System.ServiceModel.Routing.Configuration } public new BackupEndpointCollection this [string name] { - get { return (BackupEndpointCollection) BaseGet (name); } + get { + foreach (BackupEndpointCollection c in this) + if (c.Name == name) + return c; + return null; + } } } } 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 2d71ccfb003..d83b00bbbf0 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,18 @@ +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. diff --git a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/FilterElement.cs b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/FilterElement.cs index cd9ea785e7e..85de322fcea 100644 --- a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/FilterElement.cs +++ b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/FilterElement.cs @@ -13,21 +13,39 @@ namespace System.ServiceModel.Routing.Configuration public class FilterElement : ConfigurationElement { [ConfigurationProperty ("customType", DefaultValue = null, Options = ConfigurationPropertyOptions.None)] - public string CustomType { get; set; } + public string CustomType { + get { return (string) base ["customType"]; } + set { base ["customType"] = value; } + } [ConfigurationProperty ("filter1", DefaultValue = null, Options = ConfigurationPropertyOptions.None)] - public string Filter1 { get; set; } + public string Filter1 { + get { return (string) base ["filter1"]; } + set { base ["filter1"] = value; } + } [ConfigurationProperty ("filter2", DefaultValue = null, Options = ConfigurationPropertyOptions.None)] - public string Filter2 { get; set; } + public string Filter2 { + get { return (string) base ["filter2"]; } + set { base ["filter2"] = value; } + } [ConfigurationProperty ("filterData", DefaultValue = null, Options = ConfigurationPropertyOptions.None)] - public string FilterData { get; set; } + public string FilterData { + get { return (string) base ["filterData"]; } + set { base ["filterData"] = value; } + } [ConfigurationProperty ("filterType", DefaultValue = null, Options = ConfigurationPropertyOptions.IsRequired)] - public FilterType FilterType { get; set; } + 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; set; } + public string Name { + get { return (string) base ["name"]; } + set { base ["name"] = value; } + } } } 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 a87402bcbec..95a0749c6ef 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 @@ -43,6 +43,10 @@ namespace System.ServiceModel.Routing.Configuration } } + public FilterElement this [int index] { + get { return (FilterElement) BaseGet (index); } + } + public override bool IsReadOnly () { return base.IsReadOnly (); diff --git a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/FilterTableEntryCollection.cs b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/FilterTableEntryCollection.cs index f4cb3177256..799d65e3304 100644 --- a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/FilterTableEntryCollection.cs +++ b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/FilterTableEntryCollection.cs @@ -14,7 +14,10 @@ namespace System.ServiceModel.Routing.Configuration public class FilterTableEntryCollection : ConfigurationElementCollection { [ConfigurationProperty ("name", DefaultValue = null, Options = ConfigurationPropertyOptions.None | ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)] - public string Name { get; set; } + public string Name { + get { return (string) base ["name"]; } + set { base ["name"] = value; } + } public void Add (FilterTableEntryElement element) { @@ -36,11 +39,6 @@ namespace System.ServiceModel.Routing.Configuration return ((FilterTableEntryElement) element).EndpointName; } - public override bool IsReadOnly () - { - return base.IsReadOnly (); - } - public void Remove (FilterTableEntryElement element) { BaseRemove (element); diff --git a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/FilterTableEntryElement.cs b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/FilterTableEntryElement.cs index 2e267231ca3..3e9fe36074a 100644 --- a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/FilterTableEntryElement.cs +++ b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/FilterTableEntryElement.cs @@ -13,16 +13,28 @@ namespace System.ServiceModel.Routing.Configuration public class FilterTableEntryElement : ConfigurationElement { [ConfigurationProperty ("backupList", DefaultValue = null, Options = ConfigurationPropertyOptions.None)] - public string BackupList { get; set; } + 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; set; } + 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; set; } + public string FilterName { + get { return (string) base ["filterName"]; } + set { base ["filterName"] = value; } + } [ConfigurationProperty ("priority", Options = ConfigurationPropertyOptions.None)] - public int Priority { get; set; } + public int Priority { + get { return (int) base ["priority"]; } + set { base ["priority"] = value; } + } } } diff --git a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/NamespaceElement.cs b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/NamespaceElement.cs index a367c867315..b3135f92f0a 100644 --- a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/NamespaceElement.cs +++ b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/NamespaceElement.cs @@ -13,10 +13,15 @@ namespace System.ServiceModel.Routing.Configuration public class NamespaceElement : ConfigurationElement { [ConfigurationProperty ("namespace", DefaultValue = null, Options = ConfigurationPropertyOptions.IsRequired)] - public string Namespace { get; set; } + 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; set; } - + public string Prefix { + get { return (string) base ["prefix"]; } + set { base ["prefix"] = value; } + } } } diff --git a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/NamespaceElementCollection.cs b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/NamespaceElementCollection.cs index c2b0ee6ee22..6f0d75d2ec0 100644 --- a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/NamespaceElementCollection.cs +++ b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/NamespaceElementCollection.cs @@ -33,6 +33,19 @@ namespace System.ServiceModel.Routing.Configuration 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 (); diff --git a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/RoutingExtensionElement.cs b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/RoutingExtensionElement.cs index 762c9b872b9..2aca3ef8045 100644 --- a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/RoutingExtensionElement.cs +++ b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/RoutingExtensionElement.cs @@ -17,25 +17,29 @@ namespace System.ServiceModel.Routing.Configuration } [ConfigurationProperty ("filterTableName", DefaultValue = null)] - public string FilterTableName { get; set; } + public string FilterTableName { + get { return (string) base ["filterTableName"]; } + set { base ["filterTableName"] = value; } + } [ConfigurationProperty ("routeOnHeadersOnly", DefaultValue = true, Options = ConfigurationPropertyOptions.None)] - public bool RouteOnHeadersOnly { get; set; } + public bool RouteOnHeadersOnly { + get { return (bool) base ["routeOnHeadersOnly"]; } + set { base ["routeOnHeadersOnly"] = value; } + } [ConfigurationProperty ("soapProcessingEnabled", DefaultValue = true)] - public bool SoapProcessingEnabled { get; set; } + public bool SoapProcessingEnabled { + get { return (bool) base ["soapProcessingEnabled"]; } + set { base ["soapProcessingEnabled"] = value; } + } protected override object CreateBehavior () { - var sec = (RoutingSection) ConfigurationManager.GetSection ("system.serviceModel/routing"); - var re = (RoutingExtension) Activator.CreateInstance (typeof (RoutingExtension), new object [0]); - - var filters = new List<MessageFilter> (); var table = RoutingSection.CreateFilterTable (FilterTableName); - re.ApplyConfiguration (new RoutingConfiguration (table, RouteOnHeadersOnly) { - SoapProcessingEnabled = this.SoapProcessingEnabled }); - return re; + var cfg = new RoutingConfiguration (table, RouteOnHeadersOnly) { SoapProcessingEnabled = this.SoapProcessingEnabled }; + return new RoutingBehavior (cfg); } } } 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 68cde00fa00..e099f032e82 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 @@ -15,8 +15,9 @@ namespace System.ServiceModel.Routing.Configuration { public static ServiceEndpoint CreateEndpoint (this ChannelEndpointElement el) { - // FIXME: implement - throw new NotImplementedException (); + // 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) @@ -48,13 +49,14 @@ namespace System.ServiceModel.Routing.Configuration 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 (); + 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] @@ -62,43 +64,52 @@ namespace System.ServiceModel.Routing.Configuration { var sec = (RoutingSection) ConfigurationManager.GetSection ("system.serviceModel/routing"); - var filters = new Dictionary<string,MessageFilter> (); var table = new MessageFilterTable<IEnumerable<ServiceEndpoint>> (); var ftec = (FilterTableEntryCollection) sec.FilterTables [name]; foreach (FilterTableEntryElement fte in ftec) { - MessageFilter filter; - if (filters.TryGetValue (fte.FilterName, out filter)) { - var filterElement = (FilterElement) sec.Filters [fte.FilterName]; - filter = filterElement.CreateFilter (sec); - } + 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]; - foreach (BackupEndpointElement bee in bec) - list.Add (CreateServiceEndpoint (bee.EndpointName)); + 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 (); + //BackupLists = new BackupListCollection (); + //Filters = new FilterElementCollection (); + //FilterTables = new FilterTableCollection (); + //NamespaceTable = new NamespaceElementCollection (); } [ConfigurationProperty ("backupLists", Options = ConfigurationPropertyOptions.None)] - public BackupListCollection BackupLists { get; private set; } + public BackupListCollection BackupLists { + get { return (BackupListCollection) base ["backupLists"]; } + private set { base ["backupLists"] = value; } + } [ConfigurationProperty ("filters", Options = ConfigurationPropertyOptions.None)] - public FilterElementCollection Filters { get; private set; } + public FilterElementCollection Filters { + get { return (FilterElementCollection) base ["filters"]; } + private set { base ["filters"] = value; } + } [ConfigurationProperty ("filterTables", Options = ConfigurationPropertyOptions.None)] - public FilterTableCollection FilterTables { get; private set; } + public FilterTableCollection FilterTables { + get { return (FilterTableCollection) base ["filterTables"]; } + private set { base ["filterTables"] = value; } + } [ConfigurationProperty ("namespaceTable", Options = ConfigurationPropertyOptions.None)] - public NamespaceElementCollection NamespaceTable { get; private set; } + public NamespaceElementCollection NamespaceTable { + get { return (NamespaceElementCollection) base ["namespaceTable"]; } + private set { base ["namespaceTable"] = value; } + } } } diff --git a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/SoapProcessingExtensionElement.cs b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/SoapProcessingExtensionElement.cs index f6da43679b1..3694864f2e9 100644 --- a/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/SoapProcessingExtensionElement.cs +++ b/mcs/class/System.ServiceModel.Routing/System.ServiceModel.Routing.Configuration/SoapProcessingExtensionElement.cs @@ -17,7 +17,10 @@ namespace System.ServiceModel.Routing.Configuration } [ConfigurationProperty ("processMessages", DefaultValue = true, Options = ConfigurationPropertyOptions.None)] - public bool ProcessMessages { get; set; } + public bool ProcessMessages { + get { return (bool) base ["processMessages"]; } + set { base ["processMessages"] = value; } + } protected override object CreateBehavior () { |