/// <summary>
 /// When overridden in a derived class, creates a <see cref="T:System.ServiceModel.ServiceHostBase"/> with a specific base address using custom initiation data.
 /// </summary>
 /// <param name="constructorString">The initialization data that is passed to the <see cref="T:System.ServiceModel.ServiceHostBase"/> instance being constructed by the factory.</param>
 /// <param name="baseAddresses">An <see cref="T:System.Array"/> of type <see cref="T:System.Uri"/> that contains the base addresses of the host.</param>
 /// <returns>
 /// The <see cref="T:System.ServiceModel.ServiceHostBase"/> object with the specified base addresses and initialized with the custom initiation data.
 /// </returns>
 public override ServiceHostBase CreateServiceHost(
     string constructorString,
     Uri[] baseAddresses)
 {
     var container = new UnityContainer().LoadConfiguration();
     var instance = new ClientService { Container = container };
     container.BuildUp(instance);
     var serviceBusHost = new ServiceHost(instance, baseAddresses);
     return serviceBusHost;
 }
Exemplo n.º 2
0
        public Program()
        {
            Console.SetBufferSize(200, 500);
            ////Console.SetWindowSize(200, 70);

            XmlConfigurator.Configure();
            this.logger = LogManager.GetLogger(typeof(Program));

            this.container = new UnityContainer().LoadConfiguration();

            this.container.RegisterInstance(this.logger);
            this.container.RegisterInstance<ICrypto>(new Crypto());
            this.container.RegisterInstance<IFaultFactory>(new FaultFactory());

            #if Dev
            var clientService = new ClientService();
            this.container.BuildUp(clientService);
            #else
            var clientService = new ChannelFactory<IClientService>("OliveService").CreateChannel();
            #endif

            this.container.RegisterInstance<IClientService>(clientService);

            this.container.RegisterType<IOliveContext, OliveContext>();

            var rpcCredential = new NetworkCredential(
                this.settings.BitcoinDaemonUsername, this.settings.BitcoinDaemonPassword);
            this.container.RegisterInstance<IRpcClient>(new RpcClient
                {
                    Credential = rpcCredential,
            #if Dev
                    Hostname = "localhost",
            #else
                    Hostname = "oapp1.olive.local",
            #endif
                    PortNumber = this.settings.BitconDaemonPort
                });

            Console.WriteLine("Bitcoin Sync");
            Console.WriteLine();

            var sessionId = clientService.CreateSession(this.settings.ServiceEmail, this.settings.ServicePassword);

            while (true)
            {
            #if !Dev
            try
            {
            #endif
                this.ProcessWithdraws(sessionId);
                this.ProcessIncomingTransactions(sessionId);
                this.GenerateReceiveAddresses(sessionId);
            #if !Dev
            }
            catch (Exception e)
            {
                this.logger.Error("Unhandled exception: ", e);
            }
            #endif

                Thread.Sleep(5 * 1000);
            }

            Console.ReadLine();
        }
Exemplo n.º 3
0
        /// <summary>
        /// The get unity container.
        /// </summary>
        private static IUnityContainer CreateUnityContainer()
        {
            var container = new UnityContainer().LoadConfiguration();

            // Bypass service proxy for local testing
            #if Dev
            container.RegisterInstance<IFaultFactory>(new FaultFactory());
            container.RegisterType<IOliveContext, OliveContext>();

            var clientService = new ClientService();
            container.BuildUp(clientService);
            container.RegisterInstance<IClientService>(clientService);
            #else
            // Register the channel factory in code for now, because I don't know how to
            // register generic types in configuration files.
            container.RegisterType<IChannelFactory<IClientService>, ChannelFactory<IClientService>>(new ContainerControlledLifetimeManager(), new InjectionConstructor(string.Empty));

            // Register the service interface with a factory that creates it using the channel.
            container.RegisterType<IClientService>(new InjectionFactory(c => c.Resolve<ChannelFactory<IClientService>>().CreateChannel()));
            #endif

            return container;
        }