Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            Console.CursorVisible   = false;
            Console.Title           = Resources.WindowTitle;
            Console.BackgroundColor = ConsoleColor.DarkCyan;
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.Clear();
            Console.WriteLine(Resources.Header);

            ChannelServices.RegisterChannel(new TcpChannel(new Hashtable
            {
                { "port", WarehouseCommon.BookstorePort }
            }, new BinaryClientFormatterSinkProvider(), new BinaryServerFormatterSinkProvider
            {
                TypeFilterLevel = TypeFilterLevel.Full
            }), false);

            try
            {
                Bookstore.Open();
                RemotingConfiguration.RegisterActivatedServiceType(typeof(IBookstoreRemoting));
                RemotingServices.Marshal(new BookstoreRemoting(), WarehouseCommon.BookstoreEndpoint);
                LogMessage("IStoreService running on port {0:D}...", Bookstore.BaseAddresses.FirstOrDefault()?.Port);
                Webstore.Open();
                LogMessage("IWebstoreService running on port {0:D}...", Webstore.BaseAddresses.FirstOrDefault()?.Port);
                LogMessage("Press <any> key to close!");
                Console.ReadKey(true);
                Bookstore.Close();
                Webstore.Close();
            }
            catch (Exception ex)
            {
                LogException(ex);
                Console.BackgroundColor = ConsoleColor.DarkRed;
                Console.ForegroundColor = ConsoleColor.Red;
                LogMessage(Resources.ExceptionCaught);
            }
        }