Пример #1
0
        public override void Publish()
        {
            // Create the QueryHandler
            IQueryHandler queryHandler = new NHibernateQueryHandler(sessionFactory);

            #region Start the WCF server

            ServerQueryWcfHandler wcfServer = new ServerQueryWcfHandler(queryHandler);

            NetTcpBinding netTcpBinding = ServiceHelper.GetNetTcpBinding();
            string serviceUri = ServiceHelper.GetServiceUri(null, null, Artefacts.ServiceConstants.NhibernateServiceName);

            wcfServer.Start(netTcpBinding, serviceUri);

            #endregion

            #region Start the remoting server

            ServerQueryRemotingHandlerNHibernate remotingServer = new ServerQueryRemotingHandlerNHibernate(queryHandler);
            // Register default channel for remote accecss
            Hashtable properties = new Hashtable();
            properties["name"] = Artefacts.ServiceConstants.NhibernateServiceName;
            properties["port"] = Artefacts.ServiceConstants.NhibernatePort;
            IChannel currentChannel = RemotingConstants.GetDefaultChannel(properties);
            ChannelServices.RegisterChannel(currentChannel, false);
            remotingServer.Start(Artefacts.ServiceConstants.NhibernateServiceName, false);

            #endregion
        }
Пример #2
0
        /// <summary>
        /// The main method.
        /// </summary>
        static void Main()
        {
            Console.WriteLine("InterLinq.Examples.Simple.Server is going to start...");

            // Create an ExampleObjectSource
            Console.WriteLine("Creating an ExampleObjectSource...");
            ExampleObjectSource exampleObjectSource = new ExampleObjectSource();

            // Create 20 SimpleObjects and store them in the objectDataSource
            Console.WriteLine("Creating some SimpleObjects into ExampleObjectSource...");
            for (int i = 0; i < 20; i++)
            {
                SimpleObject simpleObject = new SimpleObject();
                simpleObject.Name = string.Format("Object #{0}", i);
                simpleObject.Value = i;
                exampleObjectSource.SimpleObjects.Add(simpleObject);
            }

            // Create a IQueryHandler for requests sent to this server
            Console.WriteLine("Creating an ObjectQueryHandler...");
            IQueryHandler queryHandler = new ObjectQueryHandler(exampleObjectSource);

            // Publish the IQueryHandler by InterLINQ over WCF
            Console.WriteLine("Publishing service...");
            using (ServerQueryWcfHandler serverQueryHandler = new ServerQueryWcfHandler(queryHandler))
            {
                serverQueryHandler.Start(true);
                Console.WriteLine("Server is started and running.");
                Console.WriteLine();

                // Wait for user input
                Console.WriteLine("Press [Enter] to quit.");
                Console.ReadLine();

                // Close the service
                Console.WriteLine("Closing service...");
            }
            Console.WriteLine("Bye");
        }