RoutingSection.cs :  » 2.6.4-mono-.net-core » System.ServiceModel » System » ServiceModel » Routing » Configuration » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » 2.6.4 mono .net core » System.ServiceModel 
System.ServiceModel » System » ServiceModel » Routing » Configuration » RoutingSection.cs
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;

namespace System.ServiceModel.Routing.Configuration{
  static class RoutingConfigurationExtension
  {
    public static ServiceEndpoint CreateEndpoint (this ChannelEndpointElement el)
    {
      // FIXME: implement
      throw new NotImplementedException ();
    }

    public static MessageFilter CreateFilter (this FilterElement el, RoutingSection sec)
    {
      switch (el.FilterType) {
      case FilterType.Action:
        return new ActionMessageFilter (el.FilterData);
      case FilterType.EndpointAddress:
        return new EndpointAddressMessageFilter (new EndpointAddress (el.FilterData), false);
      case FilterType.PrefixEndpointAddress:
        return new PrefixEndpointAddressMessageFilter (new EndpointAddress (el.FilterData), false);
      case FilterType.And:
        var fe1 = (FilterElement) sec.Filters [el.Filter1];
        var fe2 = (FilterElement) sec.Filters [el.Filter2];
        return new StrictAndMessageFilter (fe1.CreateFilter (sec), fe2.CreateFilter (sec));
      case FilterType.Custom:
        return (MessageFilter) Activator.CreateInstance (Type.GetType (el.CustomType));
      case FilterType.EndpointName:
        return new EndpointNameMessageFilter (el.FilterData);
      case FilterType.MatchAll:
        return new MatchAllMessageFilter ();
      case FilterType.XPath:
        return new XPathMessageFilter (el.FilterData);
      default:
        throw new ArgumentOutOfRangeException ("FilterType");
      }
    }
  }

  public class RoutingSection : ConfigurationSection
  {
    static ServiceModelSectionGroup wcfRootSection = ConfigurationManager.GetSection ("system.serviceModel") as ServiceModelSectionGroup;

    static ServiceEndpoint CreateServiceEndpoint (string name)
    {
      // FIXME: might be service endpoints.
      var endpoints = wcfRootSection.Client.Endpoints;
      return ((ChannelEndpointElement) endpoints [name]).CreateEndpoint ();
    }

    [MonoTODO]
    public static MessageFilterTable<IEnumerable<ServiceEndpoint>> CreateFilterTable (string name)
    {
      var sec = (RoutingSection) ConfigurationManager.GetSection ("system.serviceModel/routing");

      var filters = new Dictionary<string,MessageFilter> ();
      var table = new MessageFilterTable<IEnumerable<ServiceEndpoint>> ();
      var ftec = (FilterTableEntryCollection) sec.FilterTables [name];
      foreach (FilterTableEntryElement fte in ftec) {
        MessageFilter filter;
        if (filters.TryGetValue (fte.FilterName, out filter)) {
          var filterElement = (FilterElement) sec.Filters [fte.FilterName];
          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];
        foreach (BackupEndpointElement bee in bec)
          list.Add (CreateServiceEndpoint (bee.EndpointName));
      }
      return table;
    }

    public RoutingSection ()
    {
      BackupLists = new BackupListCollection ();
      Filters = new FilterElementCollection ();
      FilterTables = new FilterTableCollection ();
      NamespaceTable = new NamespaceElementCollection ();
    }

    [ConfigurationProperty ("backupLists", Options = ConfigurationPropertyOptions.None)]
    public BackupListCollection BackupLists { get; private set; }

    [ConfigurationProperty ("filters", Options = ConfigurationPropertyOptions.None)]
    public FilterElementCollection Filters { get; private set; }

    [ConfigurationProperty ("filterTables", Options = ConfigurationPropertyOptions.None)]
    public FilterTableCollection FilterTables { get; private set; }

    [ConfigurationProperty ("namespaceTable", Options = ConfigurationPropertyOptions.None)]
    public NamespaceElementCollection NamespaceTable { get; private set; }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.