Exemple #1
0
        public AwesomeServer(IOptions <AwesomeServerOptions> options, IServiceProvider serviceProvider, AwesomeFolderWatcher awesomeFolderWatcher)
        {
            var inboxPath  = options.Value.InboxPath;
            var outboxPath = options.Value.OutboxPath;

            if (!Directory.Exists(inboxPath))
            {
                Directory.CreateDirectory(inboxPath);
            }
            if (!Directory.Exists(outboxPath))
            {
                Directory.CreateDirectory(outboxPath);
            }

            var serverAddressesFeature = new ServerAddressesFeature();
            var inboxLocation          = new DirectoryInfo(inboxPath).FullName;

            serverAddressesFeature.Addresses.Add(inboxLocation);

            Features.Set <IServiceProvidersFeature>(new ServiceProvidersFeature()
            {
                RequestServices = serviceProvider
            });
            Features.Set(serverAddressesFeature);

            this.awesomeFolderWatcher = awesomeFolderWatcher;
        }
 public Task StartAsync <TContext>(IHttpApplication <TContext> application, CancellationToken cancellationToken)
 {
     return(Task.Run(() =>
     {
         var watcher = new AwesomeFolderWatcher <TContext>(application, Features);
         watcher.Watch();
     }));
 }