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 void Remove(FilterTableEntryCollection element)
 {
     if (!this.IsReadOnly())
     {
         if (element == null)
         {
             throw FxTrace.Exception.ArgumentNull("element");
         }
     }
     BaseRemove(this.GetElementKey(element));
 }
 public void Add(FilterTableEntryCollection element)
 {
     if (!this.IsReadOnly())
     {
         if (element == null)
         {
             throw FxTrace.Exception.ArgumentNull("element");
         }
     }
     BaseAdd(element);
 }
Пример #4
0
 public void Remove(FilterTableEntryCollection element)
 {
     BaseRemove(element);
 }
Пример #5
0
 public void Add(FilterTableEntryCollection element)
 {
     BaseAdd(element);
 }
Пример #6
0
		public void Remove (FilterTableEntryCollection element)
		{
			BaseRemove (element);
		}
Пример #7
0
		public void Add (FilterTableEntryCollection element)
		{
			BaseAdd (element);
		}
Пример #8
0
 public void Remove(FilterTableEntryCollection element)
 {
     if (!this.IsReadOnly())
     {
         if (element == null)
         {
             throw FxTrace.Exception.ArgumentNull("element");
         }
     }
     BaseRemove(this.GetElementKey(element));
 }
Пример #9
0
 public void Add(FilterTableEntryCollection element)
 {
     if (!this.IsReadOnly())
     {
         if (element == null)
         {
             throw FxTrace.Exception.ArgumentNull("element");
         }
     }
     BaseAdd(element);
 }