예제 #1
0
        public static IpcChannel CreateSenderChannel <TBackend>(string name, Action <IpcConfiguration> configurator = null)
            where TBackend : ISignalBackend, new()
        {
            var channel = new IpcChannel
            {
                event_communicator = new TBackend(),
                func_communicator  = new TBackend()
            };

            channel.event_communicator.Initialize(name + ".events", 4096, false);
            channel.func_communicator.Initialize(name + ".funcs", 4096, false);

            if (configurator != null)
            {
                var config = new IpcConfiguration();
                configurator(config);

                foreach (var func in config.shared_functions)
                {
                    channel.shared_functions.Add(func.Key, func.Value);
                }
            }

            return(channel);
        }
예제 #2
0
        public static IpcChannel CreateRecieverChannel <TBackend>(string name, Action <IpcConfiguration> configurator = null)
            where TBackend : ISignalBackend, new()
        {
            var channel = new IpcChannel
            {
                event_communicator = new TBackend(),
                func_communicator  = new TBackend()
            };

            if (NLog.LogManager.Configuration == null)
            {
                var config     = new NLog.Config.LoggingConfiguration();
                var logconsole = new NLog.Targets.ConsoleTarget("logconsole");

                // Rules for mapping loggers to targets
                config.AddRule(NLog.LogLevel.Trace, NLog.LogLevel.Fatal, logconsole);

                // Apply config
                NLog.LogManager.Configuration = config;
            }

            channel.event_communicator.Initialize(name + ".events", 4096, true);
            channel.func_communicator.Initialize(name + ".funcs", 4096, true);

            if (configurator != null)
            {
                var config = new IpcConfiguration();
                configurator(config);

                foreach (var func in config.shared_functions)
                {
                    channel.shared_functions.Add(func.Key, func.Value);
                }
            }

            return(channel);
        }