Beispiel #1
0
        /// <summary>
        /// Runs this program as a server.
        /// </summary>
        public static void Run(ChannelKind ChanKind, WellKnownObjectMode ObjMode, Type ObjType)
        {
            TcpChannel  tcpchan;
            HttpChannel httpchan;

            System.Collections.Hashtable httpproperties;
            System.Collections.Hashtable tcpproperties;

            Console.WriteLine("\nStarting server in WellKnownObjectMode {0}\n", ObjMode.ToString());

            switch (ChanKind)
            {
            case ChannelKind.Http:
                httpproperties         = new System.Collections.Hashtable();
                httpproperties["port"] = Server.HTTPPORT;
                httpchan = new HttpChannel(httpproperties, null, GetProviderChain());
                ChannelServices.RegisterChannel(httpchan);
                break;

            case ChannelKind.TCP:
                tcpproperties         = new System.Collections.Hashtable();
                tcpproperties["port"] = Server.TCPPORT;
                tcpchan = new TcpChannel(tcpproperties, null, GetProviderChain());
                ChannelServices.RegisterChannel(tcpchan);
                break;

            case ChannelKind.Both:
                httpproperties         = new System.Collections.Hashtable();
                httpproperties["port"] = Server.HTTPPORT;
                httpchan = new HttpChannel(httpproperties, null, GetProviderChain());
                ChannelServices.RegisterChannel(httpchan);

                tcpproperties         = new System.Collections.Hashtable();
                tcpproperties["port"] = Server.TCPPORT;
                tcpchan = new TcpChannel(tcpproperties, null, GetProviderChain());
                ChannelServices.RegisterChannel(tcpchan);
                break;

            default:
                throw new System.InvalidOperationException("Unexpected Channel kind in Server.Run()");
            }//switch

            RemotingConfiguration.RegisterWellKnownServiceType(ObjType,
                                                               "SayHello",
                                                               ObjMode);

            System.Console.WriteLine("Hit <enter> to exit...");
            System.Console.ReadLine();
            return;
        }
Beispiel #2
0
        // Convert this object into a string.
        public override String ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("type='");
            builder.Append(TypeName);
            builder.Append(", ");
            builder.Append(AssemblyName);
            builder.Append("'; objectUri=");
            builder.Append(objectUri);
            builder.Append("; mode=");
            builder.Append(mode.ToString());
            return(builder.ToString());
        }
 /// <include file='doc\RemotingConfiguration.uex' path='docs/doc[@for="WellKnownServiceTypeEntry.ToString"]/*' />
 public override String ToString()
 {
     return("type='" + TypeName + ", " + AssemblyName + "'; objectUri=" + _objectUri +
            "; mode=" + _mode.ToString());
 }
Beispiel #4
0
    }//GetOptions()

    /// <summary>
    /// Runs this program as a server.
    /// </summary>
    public static void Run(ChannelKind ChanKind, WellKnownObjectMode ObjMode, Type ObjType)
    {
      TcpChannel tcpchan;
      HttpChannel httpchan;

      Console.WriteLine("\nStarting server in WellKnownObjectMode {0}\n", ObjMode.ToString());

      switch (ChanKind)
      {
        case ChannelKind.Http:
          httpchan = new HttpChannel(Server.HTTPPORT);
          ChannelServices.RegisterChannel(httpchan);
          break;
        case ChannelKind.TCP:
          tcpchan = new TcpChannel(Server.TCPPORT);
          ChannelServices.RegisterChannel(tcpchan);
          break;
        case ChannelKind.Both:
          httpchan = new HttpChannel(Server.HTTPPORT);
          ChannelServices.RegisterChannel(httpchan);
          tcpchan = new TcpChannel(Server.TCPPORT);
          ChannelServices.RegisterChannel(tcpchan);
          break;
        default:
          throw new System.InvalidOperationException("Unexpected Channel kind in Server.Run()");
      }//switch
      
      RemotingConfiguration.RegisterWellKnownServiceType(ObjType, 
                                                         "SayHello", 
                                                         ObjMode);

      System.Console.WriteLine("Hit <enter> to exit...");
      System.Console.ReadLine();
      return;
    }