public void AddEndpoint(EndpointDispatcher endpoint) { lock (this.ThisLock) { MessageFilter endpointFilter = endpoint.EndpointFilter; int filterPriority = endpoint.FilterPriority; if (this.filters == null) { if (this.cachedEndpoints == null) { this.cachedEndpoints = new List<EndpointDispatcher>(2); } if (this.cachedEndpoints.Count < 2) { this.cachedEndpoints.Add(endpoint); } else { this.filters = new MessageFilterTable<EndpointDispatcher>(); for (int i = 0; i < this.cachedEndpoints.Count; i++) { int priority = this.cachedEndpoints[i].FilterPriority; MessageFilter filter = this.cachedEndpoints[i].EndpointFilter; this.filters.Add(filter, this.cachedEndpoints[i], priority); } this.filters.Add(endpointFilter, endpoint, filterPriority); this.cachedEndpoints = null; } } else { this.filters.Add(endpointFilter, endpoint, filterPriority); } } }
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 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 DatagramChannelDemuxer(BindingContext context) { this.filterTable = new MessageFilterTable <IChannelListener>(); this.innerListener = context.BuildInnerChannelListener <TInnerChannel>(); if (context.BindingParameters != null) { this.demuxFailureHandler = context.BindingParameters.Find <IChannelDemuxFailureHandler>(); } this.openSemaphore = new ThreadNeutralSemaphore(1); }
public SessionChannelDemuxer(BindingContext context, TimeSpan peekTimeout, int maxPendingSessions) { if (context.BindingParameters != null) { this.demuxFailureHandler = context.BindingParameters.Find <IChannelDemuxFailureHandler>(); } this.innerListener = context.BuildInnerChannelListener <TInnerChannel>(); this.filterTable = new MessageFilterTable <InputQueueChannelListener <TInnerChannel> >(); this.openSemaphore = new ThreadNeutralSemaphore(1); this.peekTimeout = peekTimeout; this.throttle = new FlowThrottle(SessionChannelDemuxer <TInnerChannel, TInnerItem> .scheduleAcceptStatic, maxPendingSessions, null, null); }
public RoutingConfiguration (MessageFilterTable<IEnumerable<ServiceEndpoint>> filterTable, bool routeOnHeadersOnly) { if (filterTable == null) { throw FxTrace.Exception.ArgumentNull("filterTable"); } this.configured = true; //User handed us the FilterTable, assume it's valid/configured this.filterTable = filterTable; this.RouteOnHeadersOnly = routeOnHeadersOnly; this.SoapProcessingEnabled = DefaultSoapProcessingEnabled; this.EnsureOrderedDispatch = DefaultEnsureOrderedDispatch; }
public RoutingConfiguration(MessageFilterTable <IEnumerable <ServiceEndpoint> > filterTable, bool routeOnHeadersOnly) { if (filterTable == null) { throw FxTrace.Exception.ArgumentNull("filterTable"); } this.configured = true; //User handed us the FilterTable, assume it's valid/configured this.filterTable = filterTable; this.RouteOnHeadersOnly = routeOnHeadersOnly; this.SoapProcessingEnabled = DefaultSoapProcessingEnabled; this.EnsureOrderedDispatch = DefaultEnsureOrderedDispatch; }
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; }
// 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; }
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); } } }
// since the OnOuterListenerOpen method will be called for every outer listener and we will open // the inner listener only once, we need to ensure that all the outer listeners wait till the // inner listener is opened. public DatagramChannelDemuxer(BindingContext context) { _filterTable = new MessageFilterTable <IServiceDispatcher>(); DemuxFailureHandler = context.BindingParameters?.Find <IChannelDemuxFailureHandler>(); }
// 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; }
protected override bool ExecuteWhere(Message target, Message messageToReadHeaders, MessageFilterTable <CorrelationKeyCalculator.SelectRuntime> whereRuntime, out CorrelationKeyCalculator.SelectRuntime select) { return(whereRuntime.GetMatchingValue(target, out select)); }
public CorrelationKeyCalculator(XName scopeName) { this.whereRuntime = new MessageFilterTable <SelectRuntime>(); this.scopeName = scopeName; this.keyCache = new CorrelationKeyCache(); }
public DatagramChannelDemuxer(IChannelDemuxFailureHandler demuxFailureHandlerPassed) { _filterTable = new MessageFilterTable <IServiceDispatcher>(); DemuxFailureHandler = demuxFailureHandlerPassed; }
public RoutingConfiguration (MessageFilterTable<IEnumerable<ServiceEndpoint>> filterTable, bool routeOnHeadersOnly) { FilterTable = filterTable; RouteOnHeadersOnly = routeOnHeadersOnly; SoapProcessingEnabled = true; }
// since the OnOuterListenerOpen method will be called for every outer listener and we will open // the inner listener only once, we need to ensure that all the outer listeners wait till the // inner listener is opened. public DatagramChannelDemuxer(BindingParameterCollection bindingParameters) { _filterTable = new MessageFilterTable <IServiceDispatcher>(); DemuxFailureHandler = bindingParameters.Find <IChannelDemuxFailureHandler>(); }
protected override bool ExecuteWhere(MessageBuffer target, Message messageToReadHeaders, MessageFilterTable <SelectRuntime> whereRuntime, out SelectRuntime select) { return(whereRuntime.GetMatchingValue(target, messageToReadHeaders, out select)); }
public RoutingConfiguration(MessageFilterTable <IEnumerable <ServiceEndpoint> > filterTable, bool routeOnHeadersOnly) { FilterTable = filterTable; RouteOnHeadersOnly = routeOnHeadersOnly; SoapProcessingEnabled = true; }
protected abstract bool ExecuteWhere(T target, Message messageToReadHeaders, MessageFilterTable <SelectRuntime> whereRuntime, out SelectRuntime select);
// since the OnOuterListenerOpen method will be called for every outer listener and we will open // the inner listener only once, we need to ensure that all the outer listeners wait till the // inner listener is opened. public DatagramChannelDemuxer() { _filterTable = new MessageFilterTable <IServiceDispatcher>(); }
protected abstract bool ExecuteWhere(T target, Message messageToReadHeaders, MessageFilterTable <CorrelationKeyCalculator.SelectRuntime> whereRuntime, out CorrelationKeyCalculator.SelectRuntime select);
public SessionChannelDemuxer(BindingParameterCollection bindingParameters)//, TimeSpan peekTimeout, int maxPendingSessions) { _filterTable = new MessageFilterTable <IServiceDispatcher>(); DemuxFailureHandler = bindingParameters.Find <IChannelDemuxFailureHandler>(); }
protected override bool ExecuteWhere(Message target, Message messageToReadHeaders, MessageFilterTable <SelectRuntime> whereRuntime, out SelectRuntime select) { // messageToReadHeaders is not used in case of MessageCalculator return(whereRuntime.GetMatchingValue(target, out select)); }