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 void TestGetPriority() { MessageFilterTable <int> table = new MessageFilterTable <int> (); MessageFilter f = new XPathMessageFilter(); table.Add(f, 0); Console.WriteLine(table.GetPriority(f)); }
public override IServiceDispatcher AddDispatcher(IServiceDispatcher innerDispatcher, ChannelDemuxerFilter filter) { lock (ThisLock) { _filterTable.Add(filter.Filter, innerDispatcher, filter.Priority); } return(this); }
public void TestGetPriority () { MessageFilterTable<int> table = new MessageFilterTable<int> (); MessageFilter f = new XPathMessageFilter (); table.Add (f, 0); Console.WriteLine (table.GetPriority (f)); }
public static MessageFilterTable <IEnumerable <ServiceEndpoint> > CreateFilterTable(string name) { if (string.IsNullOrEmpty(name)) { throw FxTrace.Exception.ArgumentNullOrEmpty("name"); } RoutingSection routingSection = (RoutingSection)ConfigurationManager.GetSection("system.serviceModel/routing"); if (routingSection == null) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.RoutingSectionNotFound)); } FilterTableEntryCollection routingTableElement = routingSection.FilterTables[name]; if (routingTableElement == null) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.RoutingTableNotFound(name))); } XmlNamespaceManager xmlNamespaces = new XPathMessageContext(); foreach (NamespaceElement nsElement in routingSection.NamespaceTable) { xmlNamespaces.AddNamespace(nsElement.Prefix, nsElement.Namespace); } FilterElementCollection filterElements = routingSection.Filters; MessageFilterTable <IEnumerable <ServiceEndpoint> > routingTable = new MessageFilterTable <IEnumerable <ServiceEndpoint> >(); foreach (FilterTableEntryElement entry in routingTableElement) { FilterElement filterElement = filterElements[entry.FilterName]; if (filterElement == null) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.FilterElementNotFound(entry.FilterName))); } MessageFilter filter = filterElement.CreateFilter(xmlNamespaces, filterElements); //retreive alternate service endpoints IList <ServiceEndpoint> endpoints = new List <ServiceEndpoint>(); if (!string.IsNullOrEmpty(entry.BackupList)) { BackupEndpointCollection alternateEndpointListElement = routingSection.BackupLists[entry.BackupList]; if (alternateEndpointListElement == null) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.BackupListNotFound(entry.BackupList))); } endpoints = alternateEndpointListElement.CreateAlternateEndpoints(); } //add first endpoint to beginning of list endpoints.Insert(0, ClientEndpointLoader.LoadEndpoint(entry.EndpointName)); routingTable.Add(filter, endpoints, entry.Priority); } return(routingTable); }
public int Add(MessageFilter filter, IChannelListener listener) { try { _rwl.AcquireWriterLock(10000); _listeners.Add(filter, listener); return(_listeners.Count); } finally { _rwl.ReleaseLock(); } }
public void AddEndpoint(EndpointDispatcher endpoint) { lock (ThisLock) { MessageFilter filter = endpoint.EndpointFilter; int priority = endpoint.FilterPriority; if (filters == null) { if (this.cachedEndpoints == null) { this.cachedEndpoints = new List<EndpointDispatcher>(optimizationThreshold); } if (this.cachedEndpoints.Count < optimizationThreshold) { this.cachedEndpoints.Add(endpoint); } else { filters = new MessageFilterTable<EndpointDispatcher>(); for (int i = 0; i < this.cachedEndpoints.Count; i++) { int cachedPriority = cachedEndpoints[i].FilterPriority; MessageFilter cachedFilter = cachedEndpoints[i].EndpointFilter; filters.Add(cachedFilter, cachedEndpoints[i], cachedPriority); } filters.Add(filter, endpoint, priority); this.cachedEndpoints = null; } } else { filters.Add(filter, endpoint, priority); } } }
// creates new table without indicated filter item MessageFilterTable <IEnumerable <ServiceEndpoint> > deltaTable(Filter filter) { var table = new MessageFilterTable <IEnumerable <ServiceEndpoint> >(); foreach (var kv in this.Router.Configuration.FilterTable) { if (filter.Equals(kv.Key)) { continue; } table.Add(kv.Key, kv.Value); } return(table); }
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; }
// creates new table without indicated filter item MessageFilterTable<IEnumerable<ServiceEndpoint>> deltaTable(Filter filter) { var table = new MessageFilterTable<IEnumerable<ServiceEndpoint>>(); foreach (var kv in this.Router.Configuration.FilterTable) { if (kv.Key.Equals(filter)) continue; table.Add(kv.Key, kv.Value); } return table; }
public static MessageFilterTable<IEnumerable<ServiceEndpoint>> CreateFilterTable(string name) { if (string.IsNullOrEmpty(name)) { throw FxTrace.Exception.ArgumentNullOrEmpty("name"); } RoutingSection routingSection = (RoutingSection)ConfigurationManager.GetSection("system.serviceModel/routing"); if (routingSection == null) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.RoutingSectionNotFound)); } FilterTableEntryCollection routingTableElement = routingSection.FilterTables[name]; if (routingTableElement == null) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.RoutingTableNotFound(name))); } XmlNamespaceManager xmlNamespaces = new XPathMessageContext(); foreach (NamespaceElement nsElement in routingSection.NamespaceTable) { xmlNamespaces.AddNamespace(nsElement.Prefix, nsElement.Namespace); } FilterElementCollection filterElements = routingSection.Filters; MessageFilterTable<IEnumerable<ServiceEndpoint>> routingTable = new MessageFilterTable<IEnumerable<ServiceEndpoint>>(); foreach (FilterTableEntryElement entry in routingTableElement) { FilterElement filterElement = filterElements[entry.FilterName]; if (filterElement == null) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.FilterElementNotFound(entry.FilterName))); } MessageFilter filter = filterElement.CreateFilter(xmlNamespaces, filterElements); //retreive alternate service endpoints IList<ServiceEndpoint> endpoints = new List<ServiceEndpoint>(); if (!string.IsNullOrEmpty(entry.BackupList)) { BackupEndpointCollection alternateEndpointListElement = routingSection.BackupLists[entry.BackupList]; if (alternateEndpointListElement == null) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.BackupListNotFound(entry.BackupList))); } endpoints = alternateEndpointListElement.CreateAlternateEndpoints(); } //add first endpoint to beginning of list endpoints.Insert(0, ClientEndpointLoader.LoadEndpoint(entry.EndpointName)); routingTable.Add(filter, endpoints, entry.Priority); } return routingTable; }