Exemplo n.º 1
0
        private static void DoWcfHost()
        {
            var reportWatch = new NStopwatch.Reportwatch();

            reportWatch.Start("ServiceHost ctor");
            using (var server = new ServiceHost(new Service(), new Uri("net.pipe://127.0.0.1/testpipename")))
            {
                reportWatch.Stop("ServiceHost ctor");

                reportWatch.Start("AddServiceEndpoint");
                var binding = new NetNamedPipeBinding {
                    MaxConnections = 5
                };
                server.AddServiceEndpoint(typeof(IService), binding, "net.pipe://127.0.0.1/testpipename");
                reportWatch.Stop("AddServiceEndpoint");

                reportWatch.Start("Open");
                server.Open();
                reportWatch.Stop("Open");

                reportWatch.Start("ChannelFactory ctor");
                using (var channelFactory = new ChannelFactory <IService>(binding))
                {
                    reportWatch.Stop("ChannelFactory ctor");

                    reportWatch.Start("CreateChannel");
                    var client = channelFactory.CreateChannel(new EndpointAddress("net.pipe://127.0.0.1/testpipename"));
                    reportWatch.Stop("CreateChannel");

                    reportWatch.Start("Execute");
                    client.Execute(new byte[0]);
                    reportWatch.Stop("Execute");
                }
            }
            reportWatch.Report("ServiceHost ctor");
            reportWatch.Report("AddServiceEndpoint");
            reportWatch.Report("Open");
            reportWatch.Report("ChannelFactory ctor");
            reportWatch.Report("CreateChannel");
            reportWatch.Report("Execute");
        }
Exemplo n.º 2
0
        private static void DoWcfHost(Binding binding, string path)
        {
            var reportWatch = new NStopwatch.Reportwatch();

            reportWatch.Start("ServiceHost ctor");
            using (var server = new ServiceHost(new Service(), new Uri(path)))
            {
                reportWatch.Stop("ServiceHost ctor");

                reportWatch.Start("AddServiceEndpoint");
                server.AddServiceEndpoint(typeof(IService), binding, path);
                reportWatch.Stop("AddServiceEndpoint");

                reportWatch.Start("Open");
                server.Open();
                reportWatch.Stop("Open");

                reportWatch.Start("ChannelFactory ctor");
                using (var channelFactory = new ChannelFactory <IService>(binding))
                {
                    reportWatch.Stop("ChannelFactory ctor");

                    reportWatch.Start("CreateChannel");
                    var client = channelFactory.CreateChannel(new EndpointAddress(path));
                    reportWatch.Stop("CreateChannel");

                    reportWatch.Start("Execute");
                    client.Execute(new byte[0]);
                    reportWatch.Stop("Execute");
                }
            }
            reportWatch.Report("ServiceHost ctor");
            reportWatch.Report("AddServiceEndpoint");
            reportWatch.Report("Open");
            reportWatch.Report("ChannelFactory ctor");
            reportWatch.Report("CreateChannel");
            reportWatch.Report("Execute");
        }
Exemplo n.º 3
0
        private static void DoWcfHost()
        {
            var reportWatch = new NStopwatch.Reportwatch();

            reportWatch.Start("ServiceHost ctor");
            using (var server = new ServiceHost(new Service(), new Uri("net.pipe://127.0.0.1/testpipename")))
            {
                reportWatch.Stop("ServiceHost ctor");

                reportWatch.Start("AddServiceEndpoint");
                var binding = new NetNamedPipeBinding { MaxConnections = 5 };
                server.AddServiceEndpoint(typeof(IService), binding, "net.pipe://127.0.0.1/testpipename");
                reportWatch.Stop("AddServiceEndpoint");

                reportWatch.Start("Open");
                server.Open();
                reportWatch.Stop("Open");

                reportWatch.Start("ChannelFactory ctor");
                using (var channelFactory = new ChannelFactory<IService>(binding))
                {
                    reportWatch.Stop("ChannelFactory ctor");

                    reportWatch.Start("CreateChannel");
                    var client = channelFactory.CreateChannel(new EndpointAddress("net.pipe://127.0.0.1/testpipename"));
                    reportWatch.Stop("CreateChannel");

                    reportWatch.Start("Execute");
                    client.Execute(new byte[0]);
                    reportWatch.Stop("Execute");
                }
            }
            reportWatch.Report("ServiceHost ctor");
            reportWatch.Report("AddServiceEndpoint");
            reportWatch.Report("Open");
            reportWatch.Report("ChannelFactory ctor");
            reportWatch.Report("CreateChannel");
            reportWatch.Report("Execute");
        }
Exemplo n.º 4
0
        private static void DoWcfHost(Binding binding, string path)
        {
            var reportWatch = new NStopwatch.Reportwatch();

            reportWatch.Start("ServiceHost ctor");
            using (var server = new ServiceHost(new Service(), new Uri(path)))
            {
                reportWatch.Stop("ServiceHost ctor");

                reportWatch.Start("AddServiceEndpoint");
                server.AddServiceEndpoint(typeof(IService), binding, path);
                reportWatch.Stop("AddServiceEndpoint");

                reportWatch.Start("Open");
                server.Open();
                reportWatch.Stop("Open");

                reportWatch.Start("ChannelFactory ctor");
                using (var channelFactory = new ChannelFactory<IService>(binding))
                {
                    reportWatch.Stop("ChannelFactory ctor");

                    reportWatch.Start("CreateChannel");
                    var client = channelFactory.CreateChannel(new EndpointAddress(path));
                    reportWatch.Stop("CreateChannel");

                    reportWatch.Start("Execute");
                    client.Execute(new byte[0]);
                    reportWatch.Stop("Execute");
                }
            }
            reportWatch.Report("ServiceHost ctor");
            reportWatch.Report("AddServiceEndpoint");
            reportWatch.Report("Open");
            reportWatch.Report("ChannelFactory ctor");
            reportWatch.Report("CreateChannel");
            reportWatch.Report("Execute");
        }