Exemple #1
0
        private static void HostServices()
        {
            EnsureQueueExists();

            List <ServiceHost> lHosts = new List <ServiceHost>();

            try
            {
                Configuration            lAppConfig    = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                ServiceModelSectionGroup lServiceModel = ServiceModelSectionGroup.GetSectionGroup(lAppConfig);

                System.ServiceModel.Configuration.ServicesSection lServices = lServiceModel.Services;
                foreach (ServiceElement lServiceElement in lServices.Services)
                {
                    ServiceHost lHost = new ServiceHost(Type.GetType(GetAssemblyQualifiedServiceName(lServiceElement.Name)));
                    lHost.Open();
                    lHosts.Add(lHost);
                }
                Console.WriteLine("VideoStore Service Started, press Q key to quit");
                while (Console.ReadKey().Key != ConsoleKey.Q)
                {
                    ;
                }
            }
            finally
            {
                foreach (ServiceHost lHost in lHosts)
                {
                    lHost.Close();
                }
            }
        }
        private void GenerateServiceConfiguration()
        {
            // Get a pointer to system.serviceModel section.
            ConfigurationSectionGroup csg = configuration.SectionGroups["system.serviceModel"];
            // Notify if we get a null reference.
            Debug.Assert(csg != null, "system.serviceModel section could not be found in the configuration.");

            if (csg != null)
            {                
                // Get a reference to the client section.
                ClientSection cs = csg.Sections["client"] as ClientSection;
                // Also get a reference to the services section.
                ServicesSection ss = csg.Sections["services"] as ServicesSection;

                // If there is no services section, we create a new one.
                if (ss == null)
                {
                    // Create a new services section.
                    ss = new ServicesSection();
                    // Add it to the sections collection.
                    csg.Sections.Add("services", ss);
                }

                string fqServiceTypeName = GetFullyQulifiedTypeName(GetServiceTypeName());
                ServiceElement se = new ServiceElement(fqServiceTypeName);
                ss.Services.Add(se);

                if (cs != null)
                {
                    foreach (ChannelEndpointElement cee in cs.Endpoints)
                    {
                        // TODO: May be we will want to give an option to use fully qulified interface names
                        // in the endpoints.
                        ServiceEndpointElement see = new ServiceEndpointElement(cee.Address, cee.Contract);
                        see.BehaviorConfiguration = cee.BehaviorConfiguration;
                        see.BindingConfiguration = cee.BindingConfiguration;
                        see.Binding = cee.Binding;
                        se.Endpoints.Add(see);
                    }
                    csg.Sections.Remove("client");
                }
            }
        }
Exemple #3
0
        private static void HostServices()
        {
            //EnsureQueueExists(transferNotifyPath);
            //EnsureQueueExists(transferPath);
            //EnsureQueueExists(transferNotifyPath);



            List <ServiceHost> lHosts = new List <ServiceHost>();

            try
            {
                Configuration            lAppConfig    = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                ServiceModelSectionGroup lServiceModel = ServiceModelSectionGroup.GetSectionGroup(lAppConfig);

                System.ServiceModel.Configuration.ServicesSection lServices = lServiceModel.Services;
                foreach (ServiceElement lServiceElement in lServices.Services)
                {
                    ServiceHost lHost = new ServiceHost(Type.GetType(GetAssemblyQualifiedServiceName(lServiceElement.Name)));
                    lHost.Open();
                    lHosts.Add(lHost);
                }
                //System.Diagnostics.Process[] pname = System.Diagnostics.Process.GetProcesses();
                //foreach(System.Diagnostics.Process x in pname)
                //{
                //    Console.WriteLine(x.ProcessName);
                //}
                Console.WriteLine(System.IO.Directory.GetCurrentDirectory());
                Console.WriteLine("BookStore Service Started, press Q key to quit");
                while (Console.ReadKey().Key != ConsoleKey.Q)
                {
                    ;
                }
            }
            finally
            {
                foreach (ServiceHost lHost in lHosts)
                {
                    lHost.Close();
                }
            }
        }
Exemple #4
0
        private void StartService()
        {
            serviceSection = (ServicesSection)WebConfigurationManager.GetSection("system.serviceModel/services");
            host = new ServiceHost(this);
            host.Open();

            channels = new List<IBackend>();
            servers = new List<DiffieHellman>();
        }