示例#1
0
文件: MyRM.cs 项目: vlung/Citicenter
        static void Main(string[] args)
        {
            RMParser parser = new RMParser();

            if (!parser.Parse(args))
            {
                return;
            }

            GlobalState.Name = parser["n"].ToLower();
            string port_num = parser["p"];

            System.Console.WriteLine(string.Format("Starting resource manager for {0} on port {1}", GlobalState.Name, port_num));

            System.Collections.Specialized.ListDictionary channelProperties = new System.Collections.Specialized.ListDictionary();
            channelProperties.Add("port", port_num);
            channelProperties.Add("name", GlobalState.Name);

            HttpChannel channel = new HttpChannel(channelProperties, new SoapClientFormatterSinkProvider(), new SoapServerFormatterSinkProvider());

            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false);
            System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType
                (Type.GetType("MyRM.MyRM")                                      // Assembly name
                , "RM.soap"                                                     // URI
                , System.Runtime.Remoting.WellKnownObjectMode.Singleton         // Instancing mode
                );

            // activate the object
            string[] urls = channel.GetUrlsForUri("RM.soap");
            if (1 != urls.Length)
            {
                throw new InvalidOperationException();
            }

            MyRM resourceManager = (MyRM)System.Activator.GetObject(typeof(TP.RM), urls[0]);

            if (null == resourceManager)
            {
                throw new InvalidProgramException();
            }

            // initialize and start RM
            Console.WriteLine("{0}: Initializing", GlobalState.Name);
            resourceManager.Init(parser["n"], urls[0], parser["tm"]);

            Console.WriteLine("{0}: Running", GlobalState.Name);
            resourceManager.Run();

            Console.WriteLine("{0}: Exitting", GlobalState.Name);
        }
示例#2
0
 /// <summary>
 ///A test for Shutdown
 ///</summary>
 //[TestMethod()]
 public void ShutdownTest()
 {
     MyRM.MyRM rm = new MyRM.MyRM(); // TODO: Initialize to an appropriate value
     rm.Shutdown();
     Assert.Inconclusive("A method that does not return a value cannot be verified.");
 }
示例#3
0
 /// <summary>
 ///A test for Shutdown
 ///</summary>
 //[TestMethod()]
 public void ShutdownTest()
 {
     MyRM.MyRM rm = new MyRM.MyRM(); // TODO: Initialize to an appropriate value
     rm.Shutdown();
     Assert.Inconclusive("A method that does not return a value cannot be verified.");
 }