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(BackupEndpointCollection element)
 {
     if (!this.IsReadOnly())
     {
         if (element == null)
         {
             throw FxTrace.Exception.ArgumentNull("element");
         }
     }
     BaseRemove(this.GetElementKey(element));
 }
 public void Add(BackupEndpointCollection element)
 {
     if (!this.IsReadOnly())
     {
         if (element == null)
         {
             throw FxTrace.Exception.ArgumentNull("element");
         }
     }
     BaseAdd(element);
 }
Beispiel #4
0
 public void Remove(BackupEndpointCollection element)
 {
     BaseRemove(element);
 }
Beispiel #5
0
 public void Add(BackupEndpointCollection element)
 {
     BaseAdd(element);
 }
Beispiel #6
0
		public void Remove (BackupEndpointCollection element)
		{
			BaseRemove (element);
		}
Beispiel #7
0
		public void Add (BackupEndpointCollection element)
		{
			BaseAdd (element);
		}
 public void Remove(BackupEndpointCollection element)
 {
     if (!this.IsReadOnly())
     {
         if (element == null)
         {
             throw FxTrace.Exception.ArgumentNull("element");
         }
     }
     BaseRemove(this.GetElementKey(element));
 }
 public void Add(BackupEndpointCollection element)
 {
     if (!this.IsReadOnly())
     {
         if (element == null)
         {
             throw FxTrace.Exception.ArgumentNull("element");
         }
     }
     BaseAdd(element);
 }