예제 #1
0
파일: Program.cs 프로젝트: orthros/MonCF
        static void Main(string[] args)
        {
            ///TODO: MEF out or make in the App.config the connection string for Mongo
            IMonCFDataStore moncfDS = new MonCFExampleDataStore("mongodb://localhost");
            IContractExtensionFactory factory = new ContractExtensionFactory();

            Func<SimpleService> factoryConstructor = () => new SimpleService(moncfDS);

            using (ServiceHost sh = new InjectionServiceHost<SimpleService>(factoryConstructor, typeof(SimpleService)))
            {
                #region Apply extensions
                try
                {
                    foreach (var endpoint in sh.Description.Endpoints)
                    {
                        factory.ApplyContractExtensions(endpoint);
                    }
                }
                catch (Exception e)
                {
                    Logger.Error("Hit an error applying the extensions to the endpoint");
                    Logger.Fatal(e.Message);
                }
                #endregion                

                #region Run
                try
                {
                    sh.Open();

                    Logger.Info("Services are running\nPress 'Enter' to stop them.");
                    Console.ReadLine();

                    sh.Close();
                }
                catch (TimeoutException timeProblem)
                {
                    Logger.Fatal(timeProblem.Message);
                    Console.ReadLine();
                }
                catch (CommunicationException commProblem)
                {
                    Logger.Fatal(commProblem.Message);
                    Console.ReadLine();
                }
                #endregion
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: orthros/MonCF
        static void Main(string[] args)
        {
            
            IContractExtensionFactory contractExtensionFactory = new ContractExtensionFactory();

            logger.Debug("Making a Proxy Factory");

            var proxyFactory = new SimpleDataServiceProxyFactory(contractExtensionFactory);

            logger.Debug("Making a proxy");

            var proxy = proxyFactory.GenerateProxy();

            logger.Debug("Making some simple data");

            var simpleData = new SimpleData();

            logger.Debug("Saving some simple data");
            proxy.SaveSimpleData(simpleData);

            logger.Info("Done doing work, press 'Enter' to exit");

            Console.ReadLine();
        }