GetUrlsForUri() private method

private GetUrlsForUri ( String objectURI ) : String[]
objectURI String
return String[]
Beispiel #1
0
		[Test] // TcpChannel (IDictionary, IClientChannelSinkProvider, IServerChannelSinkProvider)
		public void Constructor3 ()
		{
			const string SERVICE_URI = "MarshalSvc";
			string [] urls;
			ChannelDataStore ds;
			TcpChannel chn;

			MarshalObject marshal = new MarshalObject ();

			IDictionary props = new Hashtable ();
			props ["name"] = "marshal channel";
			props ["port"] = 1236;
			props ["bindTo"] = IPAddress.Loopback.ToString ();
			chn = new TcpChannel (props, null, null);

			ChannelServices.RegisterChannel (chn);

			Assert.AreEqual ("marshal channel", chn.ChannelName, "#A1");
			urls = chn.GetUrlsForUri (SERVICE_URI);
			Assert.IsNotNull (urls, "#A2");
			Assert.AreEqual (1, urls.Length, "#A3");
			Assert.AreEqual ("tcp://" + IPAddress.Loopback.ToString () + ":1236/" + SERVICE_URI, urls [0], "#A6");
			ds = chn.ChannelData as ChannelDataStore;
			Assert.IsNotNull (ds, "#A4");
			Assert.AreEqual (1, ds.ChannelUris.Length, "#A5");
			Assert.AreEqual ("tcp://" + IPAddress.Loopback.ToString () + ":1236", ds.ChannelUris [0], "#A6");

			ChannelServices.UnregisterChannel (chn);
			
			chn = new TcpChannel ((IDictionary) null, null, null);

			ChannelServices.RegisterChannel (chn);

			Assert.AreEqual ("tcp", chn.ChannelName, "#B1");
			urls = chn.GetUrlsForUri (SERVICE_URI);
			Assert.IsNull (urls, "#B1");
			ds = chn.ChannelData as ChannelDataStore;
			Assert.IsNull (ds, "#B2");

			ChannelServices.UnregisterChannel (chn);
		}
Beispiel #2
0
        static void Main(string[] args)
        {
            var serverChannel = new TcpChannel(8082);
            ChannelServices.RegisterChannel(serverChannel);
            RemotingConfiguration.ApplicationName = "TestServer";
            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(IServer), "MyServerUri", WellKnownObjectMode.SingleCall);

            // Parse the channel's URI.
            string[] urls = serverChannel.GetUrlsForUri("MyServerUri");
            if (urls.Length > 0) {
                string objectUrl = urls[0];
                string objectUri;
                string channelUri = serverChannel.Parse(objectUrl, out objectUri);
                Console.WriteLine("The object URL is {0}.", objectUrl);
                Console.WriteLine("The object URI is {0}.", objectUri);
                Console.WriteLine("The channel URI is {0}.", channelUri);
            }

            Console.WriteLine("press a key to exit");
            Console.ReadLine();
        }
Beispiel #3
0
        static int Main(string[] argv)
        {
            XmlConfigurator.Configure();
            //AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            // Get ArchAngel PID from command line arguments
            if (argv.Length != 2)
            {
                Console.WriteLine("This application cannot be run separately from ArchAngel");
                return -1;
            }

            ArchAngelPID = Int32.Parse(argv[0]);
            string uri = argv[1];

            // Create an instance of a channel
            TcpChannel channel = new TcpChannel(0);
            ChannelServices.RegisterChannel(channel, false);

            // Register as an available service with the name CommandReceiver
            // Register as a Singleton so only one runs at a time.
            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(CommandReceiver),
                "CommandReceiver",
                WellKnownObjectMode.Singleton);

            ThreadStart start = SearchForArchAngelProcess;
            Thread thread = new Thread(start);
            thread.Start();

            DebugProcessInfoService dpis = (DebugProcessInfoService)Activator.GetObject(
                               typeof(DebugProcessInfoService), uri);

            if (dpis == null)
            {
                // ArchAngel is either not running or not responding. The process should die either way.
                EndDebugProcess.Set();
            }
            else
            {
                // Get the URI of our remoting services, so we can tell the ArchAngel
                // process how to contact us.
                string objectUri = "";
                string[] urls = channel.GetUrlsForUri("CommandReceiver");
                if (urls.Length > 0)
                {
                    string objectUrl = urls[0];
                    string channelUri = channel.Parse(objectUrl, out objectUri);
                    objectUri = channelUri + objectUri;
                }
                if (string.IsNullOrEmpty(objectUri))
                {
                    throw new Exception(
                        "The Debug Process could not register itself with .Net" +
                        "remoting. This is a serious error and must be reported to Slyce.");
                }

                // Inform ArchAngel that we have started.
                dpis.Started(objectUri);
            }

            // Wait for the signal to end the app.
            EndDebugProcess.WaitOne();
            return 0;
        }