internal void ApplyConfiguration(NetNamedPipeSecurity security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } security.Mode = this.Mode; this.Transport.ApplyConfiguration(security.Transport); }
internal void InitializeFrom(NetNamedPipeSecurity security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } this.Mode = security.Mode; this.Transport.InitializeFrom(security.Transport); }
internal void InitializeFrom(NetNamedPipeSecurity security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } SetPropertyValueIfNotDefaultValue(ConfigurationStrings.Mode, security.Mode); this.Transport.InitializeFrom(security.Transport); }
// Host the service within this EXE console application. public static void Main() { // Get base address from app settings in configuration Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service"); // Create a ServiceHost for the CalculatorService type and provide the base address. using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress)) { // <Snippet1> NetNamedPipeBinding nnpb = new NetNamedPipeBinding(); NetNamedPipeSecurity nnpSecurity = nnpb.Security; // <Snippet2> nnpSecurity.Mode = NetNamedPipeSecurityMode.Transport; // </Snippet2> // <Snippet3> NamedPipeTransportSecurity npts = nnpSecurity.Transport; // </Snippet3> serviceHost.AddServiceEndpoint(typeof(ICalculator), nnpb, "net.pipe://localhost/ServiceModelSamples/Service"); // </Snippet1> // Add a mex endpoint ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true; smb.HttpGetUrl = new Uri("http://localhost:8000/servicemodelsamples/service"); serviceHost.Description.Behaviors.Add(smb); // Open the ServiceHostBase to create listeners and start listening for messages. serviceHost.Open(); // The service can now be accessed. Console.WriteLine("The service is ready."); Console.WriteLine("Press <ENTER> to terminate service."); Console.WriteLine(); Console.ReadLine(); // Close the ServiceHostBase to shutdown the service. serviceHost.Close(); } }
public static void Main() { Uri baseAddress = new Uri("http://localhost:8000/uesamples/service"); string address = "net.pipe://localhost/uesamples/calc"; // Create a ServiceHost for the CalculatorService type and provide the base address. using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress)) { NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None); serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, address); // Add a mex endpoint ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true; smb.HttpGetUrl = new Uri("http://localhost:8001/uesamples"); serviceHost.Description.Behaviors.Add(smb); //<Snippet5> long maxBufferPoolSize = binding.MaxBufferPoolSize; //</Snippet5> //<Snippet6> int maxBufferSize = binding.MaxBufferSize; //</Snippet6> //<Snippet7> int maxConnections = binding.MaxConnections; //</Snippet7> //<Snippet8> long maxReceivedMessageSize = binding.MaxReceivedMessageSize; //</Snippet8> //<Snippet9> NetNamedPipeSecurity security = binding.Security; //</Snippet9> //<Snippet10> string scheme = binding.Scheme; //</Snippet10> //<Snippet11> XmlDictionaryReaderQuotas readerQuotas = binding.ReaderQuotas; //</Snippet11> //<Snippet12> BindingElementCollection bCollection = binding.CreateBindingElements(); //</Snippet12> //<Snippet13> HostNameComparisonMode hostNameComparisonMode = binding.HostNameComparisonMode; //</Snippet13> //<Snippet14> bool TransactionFlow = binding.TransactionFlow; //</Snippet14> //<Snippet15> TransactionProtocol transactionProtocol = binding.TransactionProtocol; //</Snippet15> //<Snippet16> EnvelopeVersion envelopeVersion = binding.EnvelopeVersion; //</Snippet16> //<Snippet18> TransferMode transferMode = binding.TransferMode; //</Snippet18> serviceHost.Open(); Console.WriteLine("The service is ready."); Console.WriteLine("Press <ENTER> to terminate service."); Console.WriteLine(); Console.ReadLine(); serviceHost.Close(); } }