コード例 #1
0
        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);
        }
コード例 #2
0
 public void Remove(FilterTableEntryCollection element)
 {
     if (!this.IsReadOnly())
     {
         if (element == null)
         {
             throw FxTrace.Exception.ArgumentNull("element");
         }
     }
     BaseRemove(this.GetElementKey(element));
 }
コード例 #3
0
 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);
 }