Exemplo n.º 1
0
        public static TContract CreateChannel <TContract>(IPCType ipcType, string address)
        {
            Binding binding;

            switch (ipcType)
            {
            case IPCType.NamedPipe:
                binding = new NetNamedPipeBinding("");
                break;

            case IPCType.TCP:
                binding = new NetTcpBinding("")
                {
                    Security =
                    {
                        Mode = SecurityMode.None
                    }
                };
                break;

            default:
                throw new InvalidEnumArgumentException(nameof(ipcType), (int)ipcType, ipcType.GetType());
            }

            var factory = new ChannelFactory <TContract>(binding, address);

            return(factory.CreateChannel());
        }
Exemplo n.º 2
0
        public static ServiceHost CreateService(IPCType ipcType, Type serviceType, Type contractType, out Uri uri)
        {
            switch (ipcType)
            {
            case IPCType.NamedPipe:
                return(CreateNamedPipeService(serviceType, contractType, out uri));

            case IPCType.TCP:
                return(CreateTcpService(serviceType, contractType, out uri));

            default:
                throw new InvalidEnumArgumentException(nameof(ipcType), (int)ipcType, ipcType.GetType());
            }
        }