public LogModel(ILog log,ICommandRouter router) { Hierarchy h = LogManager.GetRepository() as Hierarchy; h.Root.AddAppender(this); h.Root.Level = Level.Debug; this.log = log; router.ExceptionExecuting += new EventHandler<ExecutingExceptionEventArgs>(router_ExceptionExecuting); channel = new IpcChannel("log4net"); ChannelServices.RegisterChannel(channel,false); oref = RemotingServices.Marshal(this, null); ApplicationEnvironment.Instance.LoggerURI = channel.GetUrlsForUri(oref.URI)[0]; }
public static void ActivateApi() { log.Info("Activating API"); var serverSinkProvider = new BinaryServerFormatterSinkProvider { TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full }; IDictionary properties = new Hashtable(); properties["portName"] = System.Configuration.ConfigurationManager.AppSettings["ApiPort"] ?? "localhost:19888"; properties["authorizedGroup"] = System.Configuration.ConfigurationManager.AppSettings["ApiAccessGroup"] ?? "Interactive"; var serverChannel = new IpcChannel(properties, null, serverSinkProvider); ChannelServices.RegisterChannel(serverChannel,true); log.DebugFormat(" - The name of the channel is {0}.",serverChannel.ChannelName); log.DebugFormat(" - The priority of the channel is {0}.", serverChannel.ChannelPriority); var channelData = (ChannelDataStore)serverChannel.ChannelData; foreach (var uri in channelData.ChannelUris) { log.DebugFormat(" - The channel URI is {0}.", uri); } RemotingConfiguration.RegisterWellKnownServiceType( typeof(API),"API",WellKnownObjectMode.Singleton ); var urls = serverChannel.GetUrlsForUri("API"); if (urls.Length > 0) { string objectUrl = urls[0]; string objectUri; string channelUri = serverChannel.Parse(objectUrl, out objectUri); log.DebugFormat("The object URI is {0}.", objectUri); log.DebugFormat("The channel URI is {0}.", channelUri); log.DebugFormat("The object URL is {0}.", objectUrl); } }
public void TestCtor3 () { string portName = "ipc" + Guid.NewGuid ().ToString ("N"); string url = String.Format ("ipc://{0}/server.rem", portName); Hashtable props = new Hashtable (); props ["portName"] = portName; IpcChannel chan = new IpcChannel (props, null, null); string[] uris = chan.GetUrlsForUri ("server.rem"); Assert.IsNotNull (uris); Assert.Greater (uris.Length, 0); bool found = false; foreach (string s in uris) { if (s == url) { found = true; break; } } Assert.IsTrue (found); }