示例#1
0
 /// <summary>
 /// TODO: Add summary here.
 /// </summary>
 /// <param name="context"></param>
 public void StartService(ApplicationServiceContext context)
 {
     if (!this.HasStarted)
     {
         this.HasStarted = true;
     }
 }
示例#2
0
        /// <summary>
        /// Called by an application in order to initialize the application extension service.
        /// </summary>
        /// <param name="context">Provides information about the application state. </param>
        public void StartService(ApplicationServiceContext context)
        {
            var logLevel = LogSeverityLevel;

            if (context.ApplicationInitParams.ContainsKey(Constants.INIT_PARAM_LOGLEVEL))
            {
                logLevel =
                    (LogSeverity)
                    Enum.Parse(typeof(LogSeverity), context.ApplicationInitParams[Constants.INIT_PARAM_LOGLEVEL], true);
            }

            _mainCatalog = new AggregateCatalog(new DeploymentCatalog()); // empty one adds current deployment (xap)

            _container = new CompositionContainer(_mainCatalog);

            CompositionHost.Initialize(_container);
            CompositionInitializer.SatisfyImports(this);

            if (Logger == null)
            {
                ILogger defaultLogger = new DefaultLogger(logLevel);
                _container.ComposeExportedValue(defaultLogger);
            }
            else
            {
                Logger.SetSeverity(logLevel);
            }

            DeploymentService.Catalog   = _mainCatalog;
            DeploymentService.Container = _container;
            _mefDebugger = new MefDebugger(_container, Logger);
        }
示例#3
0
        /// <summary>
        /// Called by an application in order to initialize the application extension service.
        /// </summary>
        /// <param name="context">Provides information about the application state.</param>
        public virtual void StartService(ApplicationServiceContext context)
        {
            _current = (TService)this;

            // added to allow for xaml binding.
            Application.Current.Resources.Add(ServiceName, this);
            Logger <TService> .Info("Service '{0}' Started.", ServiceName);
        }
示例#4
0
        /// <summary>
        /// Called by an application in order to initialize the application extension service.
        /// </summary>
        /// <param name="context">Provides information about the application state. </param>
        public void StartService(ApplicationServiceContext context)
        {
            if (DesignerProperties.IsInDesignTool)
            {
                return;
            }

            Current = this;
        }
示例#5
0
 /// <summary>
 /// 启动本地数据库服务
 /// </summary>
 /// <param name="context">应用程序池</param>
 public void StartService(ApplicationServiceContext context)
 {
     if (DesignerProperties.IsInDesignTool)
     {
         return;
     }
     sengine = new SterlingEngine();
     Current = this;
 }
示例#6
0
 public void StartService(ApplicationServiceContext context)
 {
     CompositionHost.Initialize(
         new AssemblyCatalog(
             Application.Current.GetType().Assembly),
         new AssemblyCatalog(typeof(AnalyticsEvent).Assembly),
         new AssemblyCatalog(typeof(TrackAction).Assembly));
     _innerService.StartService(context);
 }
        public void Can_throw_on_non_valid_payload()
        {
            // Arrange.
            var kernel = new StandardKernel();

            kernel.Bind <PayloadValidator>().ToSelf().InSingletonScope();
            kernel.Bind <IValidator <TestApplicationService.TestPayload> >().To <TestApplicationService.TestPayloadValidator>().InSingletonScope();
            kernel.Bind <PayloadValidationFilter <ApplicationServiceContext, PipelineContext> >().ToSelf().InSingletonScope();

            var filter  = kernel.Get <PayloadValidationFilter <ApplicationServiceContext, PipelineContext> >();
            var service = new TestApplicationService();
            var context = new ApplicationServiceContext(new TestApplicationService.TestPayload());

            // Act & Assert.
            Assert.Throws <PayloadValidationException>(() => filter.Process(context, new PipelineContext(service)));
        }
        public void Can_invoke_service_without_filters()
        {
            // Assert.
            var kernel = new StandardKernel();

            kernel.BindApplicationServicePipeline();

            var payload = new EchoPayloadValueService.Payload {
                Value = 1
            };
            var context = new ApplicationServiceContext(payload);

            // Act.
            var result = kernel.Get <ApplicationServiceInvoker>().Invoke <EchoPayloadValueService, EchoPayloadResult>(context);

            // Assert.
            result.Value.ShouldBe(1);
        }
示例#9
0
        public static OrderModule Initialize(IReliableStateManager stateManager, Func <ITransaction, IEventStore> store, Func <ITransaction, IEvent[], Task> outbox, Func <IEvent[], Task> eventLogger)
        {
            var commandDispatcher = new Dispatcher <ICommand, Task>();
            var policies          = new EventProcessor();
            var projections       = new EventProcessor();
            var queryDispatcher   = new QueryDispatcher();
            var queueSerializer   = Serialization.Json();

            var publisher = new EventPublisher(outbox, eventLogger, (tx, evts) => projections.PublishAsync(evts));
            var context   = new ApplicationServiceContext(stateManager, store, publisher);

            commandDispatcher
            .WithContext(context)
            .Register <CreateOrderCommand>(CreateOrderApplicationService.ExecuteAsync);

            policies.RegisterReceptor <CartCheckedoutEvent>(commandDispatcher, FooPolicy.When);

            return(new OrderModule(commandDispatcher, policies.Merge(projections.PublishAsync), queryDispatcher));
        }
示例#10
0
    /// <summary>
    /// Raises the <see cref="E:System.Windows.Application.Startup"/> event.
    /// </summary>
    /// <param name="e">A <see cref="T:System.Windows.StartupEventArgs"/> that contains the event data.</param>
    protected override void OnStartup(StartupEventArgs e)
    {
      var applicationServiceContext = new ApplicationServiceContext();

      foreach (IApplicationService service in ApplicationLifetimeObjects)
      {
        service.StartService(applicationServiceContext);

        var aware = service as IApplicationLifetimeAware;
        if (aware != null)
          aware.Starting();
      }

      base.OnStartup(e);

      ApplicationLifetimeObjects
        .OfType<IApplicationLifetimeAware>()
        .ForEach(a => a.Started());

    }
示例#11
0
        /// <summary>
        /// Called by an application in order to initialize the application extension service.
        /// </summary>
        /// <param name="context">Provides information about the application state. </param>
        public void StartService(ApplicationServiceContext context)
        {
            if (!context.ApplicationInitParams.ContainsKey("feedUri"))
            {
                throw new Exception("Must be configured with the feed.");
            }

            var mode = context.ApplicationInitParams.ContainsKey("mode")
                           ? context.ApplicationInitParams["mode"]
                           : "Mock";

            if (string.IsNullOrEmpty(mode))
            {
                mode = "Mock";
            }

            Mode = mode;

            FeedUri = new Uri(context.ApplicationInitParams["feedUri"], UriKind.Absolute);
        }
示例#12
0
        public static CartModule Initialize(
            IReliableStateManager stateManager,
            Func <ITransaction, IEventStore> store,
            Func <ITransaction, IEvent[], Task> outbox,
            Func <IEvent[], Task> eventLogger)
        {
            var commandDispatcher = new Dispatcher <ICommand, Task>();
            var policies          = new EventProcessor();
            var projections       = new EventProcessor();
            var queryDispatcher   = new QueryDispatcher();

            var publisher = new EventPublisher(outbox, eventLogger, (tx, evts) => projections.PublishAsync(evts));
            var context   = new ApplicationServiceContext(stateManager, store, publisher);

            commandDispatcher
            .WithContext(context)
            .Register <AddItemCommand>(AddItemApplicationService.ExecuteAsync)
            .Register <CheckoutCommand>(CheckoutApplicationService.ExecuteAsync);

            return(new CartModule(commandDispatcher, policies.Merge(projections.PublishAsync), queryDispatcher));
        }
 public void StartService(ApplicationServiceContext context)
 {
     Current = this;
 }
示例#14
0
 public static Task ExecuteAsync(ApplicationServiceContext context, CreateOrderCommand command)
 => context.ExecuteAsync <OrderState>(command, state => new[] { new OrderCreatedEvent(Guid.Parse(command.AggregateId.ToString())) });
示例#15
0
 void IApplicationService.StartService(ApplicationServiceContext context)
 {
 }
示例#16
0
 void IApplicationService.StartService(ApplicationServiceContext context)
 {
     _dispatcherTimer.Start();
 }
示例#17
0
 public static Task ExecuteAsync(ApplicationServiceContext context, CheckoutCommand command)
 => context.ExecuteAsync <CartState>(command, state => new[] { new CartCheckedoutEvent(Guid.Parse(command.AggregateId.Id)) });
示例#18
0
 public void StartService(ApplicationServiceContext context)
 {
     CompositionHost.Initialize(
         new AssemblyCatalog(Application.Current.GetType().Assembly),
         new AssemblyCatalog(typeof(AnalyticsEvent).Assembly),
         new AssemblyCatalog(typeof(TrackAction).Assembly),
         new AssemblyCatalog(typeof(GoogleAnalytics).Assembly));
     _innerService.StartService(context);
 }
 public void StartService(ApplicationServiceContext context)
 {
     _frameworkDispatcherTimer.Start();
 }
 void IApplicationService.StartService(ApplicationServiceContext context)
 {
     timer.Start();
 }
示例#21
0
 public void StartService(ApplicationServiceContext context = null)
 {
     this._timer.Start();
 }
示例#22
0
 public void StartService(ApplicationServiceContext context)
 {
     _timer.Start();
 }
示例#23
0
 void IApplicationService.StartService(ApplicationServiceContext context)
 {
     this.frameworkDispatcherTimer.Start();
 }
示例#24
0
 /// <summary>
 /// Called by an application in order to initialize the application extension service.
 /// </summary>
 /// <param name="context">Provides information about the application state.</param>
 public void StartService(ApplicationServiceContext context)
 {
 }
 void IApplicationService.StartService(ApplicationServiceContext context)
 {
     LoadConfigSettings();
 }
示例#26
0
 public static Task ExecuteAsync(ApplicationServiceContext context, AddItemCommand command)
 => context.ExecuteAsync <CartState>(command, state => new[] { new ItemAddedEvent(command.AggregateId) });