Beispiel #1
0
        public static IApp StartRemote(
            string?remoteApp           = null,
            string?xamlTestPath        = null,
            Action <string>?logMessage = null)
        {
            xamlTestPath ??= Path.ChangeExtension(Assembly.GetExecutingAssembly().Location, ".exe");
            xamlTestPath = Path.GetFullPath(xamlTestPath);
            if (!File.Exists(xamlTestPath))
            {
                throw new Exception($"Could not find test app '{xamlTestPath}'");
            }

            var startInfo = new ProcessStartInfo(xamlTestPath)
            {
                WorkingDirectory = Path.GetDirectoryName(xamlTestPath) + Path.DirectorySeparatorChar,
                UseShellExecute  = true
            };

            if (!string.IsNullOrWhiteSpace(remoteApp))
            {
                startInfo.Arguments = remoteApp;
            }

            Process process = Process.Start(startInfo);
            var     channel = new NamedPipeChannel(".", Server.PipePrefix + process.Id);
            var     client  = new Protocol.ProtocolClient(channel);

            return(new ManagedApp(process, client, logMessage));
        }
        public override TestService.TestServiceClient CreateClient()
        {
            var channel = new NamedPipeChannel(".", _pipeName, new NamedPipeChannelOptions {
                ConnectionTimeout = _connectionTimeout
            });

            return(new TestService.TestServiceClient(channel));
        }
 public IChannel CreateChannel( IChannelDefinition definition )
 {
     var namedPipeChannelDefinition = definition as NamedPipeChannelDefinition;
     var serializer = Assimilate.GetInstanceOf( definition.SerializerType ) as IMessageSerializer;
     var proxy = new PipeProxy( namedPipeChannelDefinition, Dispatcher, serializer );
     var namedPipeChannel = new NamedPipeChannel( namedPipeChannelDefinition, proxy, Dispatcher );
     return namedPipeChannel;
 }
Beispiel #4
0
 private static Func <IServiceProvider, NamedPipeChannel> CreateConfiguredNamedPipeChannel()
 {
     return(serviceProvider =>
     {
         var options = new NamedPipeChannelOptions();
         options.ConnectionTimeout = (int)TimeSpan.FromSeconds(3).TotalMilliseconds;
         var channel = new NamedPipeChannel(".", Globals.NamedPipeChannel, options);
         return channel;
     });
 }
 public VoiceRecognitionUpdateService(ILogger <VoiceRecognitionUpdateService> log,
                                      IServiceScopeFactory serviceScopeFactory,
                                      NamedPipeChannel namedPipeChannel,
                                      ApplicationStateTransmitter applicationStateTransmitter)
 {
     _log = log;
     _serviceScopeFactory         = serviceScopeFactory;
     _namedPipeChannel            = namedPipeChannel;
     _applicationStateTransmitter = applicationStateTransmitter;
 }
Beispiel #6
0
        static async Task Main(string[] args)
        {
            var channel = new NamedPipeChannel(".", "MY_PIPE_NAME");
            var client  = new Greeter.GreeterClient(channel);

            var response = await client.SayHelloAsync(
                new HelloRequest { Name = "World" });

            Console.WriteLine(response.Message);
            Console.ReadKey();
        }
Beispiel #7
0
        public static IApp ConnectToApp(Process process)
        {
            if (process is null)
            {
                throw new ArgumentNullException(nameof(process));
            }

            var channel = new NamedPipeChannel(".", Server.PipePrefix + process.Id);
            var client  = new Protocol.ProtocolClient(channel);

            return(new Internal.App(client));
        }
Beispiel #8
0
        public static IApp StartRemote(string?path = null)
        {
            path ??= Path.ChangeExtension(Assembly.GetExecutingAssembly().Location, ".exe");
            path = Path.GetFullPath(path);
            if (!File.Exists(path))
            {
                throw new Exception($"Could not find test app '{path}'");
            }

            var startInfo = new ProcessStartInfo(path)
            {
                WorkingDirectory = Path.GetDirectoryName(path) + Path.DirectorySeparatorChar,
            };
            Process process = Process.Start(startInfo);
            var     channel = new NamedPipeChannel(".", Server.PipePrefix + process.Id);
            var     client  = new Protocol.ProtocolClient(channel);

            return(new ManagedApp(process, client));
        }
Beispiel #9
0
        static async Task Main(string[] args)
        {
            try
            {
                Console.WriteLine("Starting service.");
                var channel           = new NamedPipeChannel(".", "Test");
                var chatServiceClient = new ChatService.ChatServiceClient(channel);

                Console.WriteLine("Press enter if your message is empty to abort the program.");
                while (true)
                {
                    Console.Write("You: ");
                    var content = Console.ReadLine();
                    if (string.IsNullOrEmpty(content))
                    {
                        return;
                    }

                    Console.WriteLine("Sending message ...");
                    var response = await chatServiceClient.SendMessageAsync(new ChatRequest()
                    {
                        Name = content
                    });

                    Console.WriteLine($"Received: {response.Message}");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                Console.ReadKey();
            }
        }
        public override TestService.TestServiceClient CreateClient()
        {
            var channel = new NamedPipeChannel(".", _pipeName);

            return(new TestService.TestServiceClient(channel));
        }
Beispiel #11
0
 public UserContextChannel(NamedPipeChannel channel, ILogger <UserContextChannel> logger)
 {
     _logger  = logger;
     _service = new DesktopIntegrationService.DesktopIntegrationServiceClient(channel);
 }