public override Task OnRecordAddedAsync(IRecordStore store, Record record,
                                                CancellationToken cancellationToken = default)
        {
            var pending = AsyncExtensions.TaskPool.Get();

            try
            {
                var notify = _notify.Clients.All.SendAsync(Constants.Notifications.ReceiveMessage, "info",
                                                           $"Added new record with ID '{record.Uuid}'", cancellationToken);
                if (notify.IsCompleted || notify.IsCanceled || notify.IsFaulted)
                {
                    return(AsyncExtensions.NoTask);
                }

                if (notify.Status != TaskStatus.Running)
                {
                    notify.Start();
                }

                pending.Add(notify);
                return(Task.WhenAll(pending));
            }
            finally
            {
                AsyncExtensions.TaskPool.Return(pending);
            }
        }
Esempio n. 2
0
		public MI_Replay (CMenu menu, IRecordStore store)
			: base ("replay")
		{
			if (menu == null) {
				throw new ArgumentNullException ("menu");
			}
			if (store == null) {
				throw new ArgumentNullException ("store");
			}

			_Store = store;

			HelpText = ""
				+ "replay [name]\n"
				+ "Replays all commands stored in the specified file name, or\n"
				+ "Displays a list of all records.\n"
				+ "\n"
				+ "Replaying puts all stored commands in the same order on the stack as they were originally entered.\n"
				+ "Replaying stops when the line \"" + EndReplayCommand + "\" is encountered.";

			if (menu == null) {
				throw new ArgumentNullException ("menu");
			}

			_Menu = menu;
		}
        public async Task RebuildAsync(IRecordStore store, CancellationToken cancellationToken = default)
        {
            _index = await Index.Build(async builder =>
            {
                var fields = new HashSet <string>();
                var sw     = Stopwatch.StartNew();
                var count  = 0UL;

                await foreach (var entry in store.StreamRecordsAsync(cancellationToken))
                {
                    foreach (var column in entry.Columns.Where(column => !fields.Contains(column.Name)))
                    {
                        builder.AddField(column.Name);
                        fields.Add(column.Name);
                    }

                    var document = new Document {
                        { "id", entry.Uuid }
                    };
                    foreach (var column in entry.Columns)
                    {
                        document.Add(column.Name, column.Value);
                    }

                    await builder.Add(document);
                    count++;
                }

                _logger?.LogInformation($"Indexing {count} documents took {sw.Elapsed.TotalMilliseconds}ms");
            });
        }
Esempio n. 4
0
        public MI_Replay(CMenu menu, IRecordStore store)
            : base("replay")
        {
            if (menu == null)
            {
                throw new ArgumentNullException("menu");
            }
            if (store == null)
            {
                throw new ArgumentNullException("store");
            }

            _Store = store;

            HelpText = ""
                       + "replay [name]\n"
                       + "Replays all commands stored in the specified file name, or\n"
                       + "Displays a list of all records.\n"
                       + "\n"
                       + "Replaying puts all stored commands in the same order on the stack as they were originally entered.\n"
                       + "Replaying stops when the line \"" + EndReplayCommand + "\" is encountered.";

            if (menu == null)
            {
                throw new ArgumentNullException("menu");
            }

            _Menu = menu;
        }
        public DynamicController(IRecordStore store, ICacheRegion <SyndicationFeed> feeds)
        {
            _store   = store;
            _feeds   = feeds;
            _example = new T();

            ObjectValidator = new DynamicModelValidator();
        }
Esempio n. 6
0
        /// <summary>
        /// Initializes all required modules for the game.
        /// </summary>
        protected virtual void InitializeModules()
        {
            UnityThread.Initialize();

            Dependencies.CacheAs <IGame>(this);

            Dependencies.CacheAs <IPlatformHost>(platformHost = PlatformHost.CreateHost());
            Dependencies.CacheAs <DeepLinker>(deepLinker      = platformHost.CreateDeepLinker());

            Dependencies.CacheAs <IEnvConfiguration>(envConfiguration = new EnvConfiguration(EnvType.Production));

            Dependencies.CacheAs <IModeManager>(modeManager = new ModeManager());

            Dependencies.CacheAs <INotificationBox>(notificationBox = new NotificationBox());

            Dependencies.CacheAs <IGameConfiguration>(gameConfiguration     = new GameConfiguration());
            Dependencies.CacheAs <IMapConfiguration>(mapConfiguration       = new MapConfiguration());
            Dependencies.CacheAs <IMapsetConfiguration>(mapsetConfiguration = new MapsetConfiguration());

            Dependencies.CacheAs <IFontManager>(fontManager       = new FontManager());
            Dependencies.CacheAs <IAtlas <Sprite> >(spriteAtlas   = new ResourceSpriteAtlas());
            Dependencies.CacheAs <IAtlas <AudioClip> >(audioAtlas = new ResourceAudioAtlas());

            Dependencies.CacheAs <IMusicCacher>(musicCacher           = new MusicCacher());
            Dependencies.CacheAs <IBackgroundCacher>(backgroundCacher = new BackgroundCacher());
            Dependencies.CacheAs <IWebImageCacher>(webImageCacher     = new WebImageCacher());
            Dependencies.CacheAs <IWebMusicCacher>(webMusicCacher     = new WebMusicCacher());

            Dependencies.CacheAs <IMusicController>(musicController = MusicController.Create());

            Dependencies.CacheAs <ISoundTable>(soundTable = new DefaultSoundTable(audioAtlas));
            Dependencies.CacheAs <ISoundPool>(soundPool   = new SoundPool(soundTable));

            Dependencies.CacheAs <IMapsetStore>(mapsetStore   = new MapsetStore(modeManager));
            Dependencies.CacheAs <IMapSelection>(mapSelection = new MapSelection(musicCacher, backgroundCacher, gameConfiguration, mapsetConfiguration, mapConfiguration));
            Dependencies.CacheAs <IMapManager>(mapManager     = new MapManager(mapsetStore, notificationBox, mapSelection));
            Dependencies.CacheAs <IMetronome>(metronome       = new Metronome()
            {
                AudioController = musicController
            });
            Dependencies.CacheAs <IMusicPlaylist>(musicPlaylist = new MusicPlaylist());

            Dependencies.CacheAs <IDownloadStore>(downloadStore = new DownloadStore());
            Dependencies.CacheAs <IApi>(api = new Api(envConfiguration, notificationBox, deepLinker));

            Dependencies.CacheAs <IUserManager>(userManager = new UserManager(api, Dependencies));
            Dependencies.CacheAs <IRecordStore>(recordStore = new RecordStore());

            Dependencies.CacheAs <IRootMain>(rootMain                 = RootMain.Create(Dependencies));
            Dependencies.CacheAs <IRoot3D>(root3D                     = Root3D.Create(Dependencies));
            Dependencies.CacheAs <IColorPreset>(colorPreset           = new ColorPreset());
            Dependencies.CacheAs <IAnimePreset>(animePreset           = new AnimePreset());
            Dependencies.CacheAs <IScreenNavigator>(screenNavigator   = new ScreenNavigator(rootMain));
            Dependencies.CacheAs <IOverlayNavigator>(overlayNavigator = new OverlayNavigator(rootMain));
            Dependencies.CacheAs <IDropdownProvider>(dropdownProvider = new DropdownProvider(rootMain));

            Dependencies.CacheAs <ITemporaryStore>(temporaryStore = new TemporaryStore());
        }
Esempio n. 7
0
 public DaemonService(PeerBus bus, IOntologyLog ontology, ILogStore logs, IRecordStore records,
                      RecordEvents events, IOptionsMonitor <WebServerOptions> options, ILogger <DaemonService> logger)
 {
     _bus      = bus;
     _ontology = ontology;
     _logs     = logs;
     _records  = records;
     _events   = events;
     _options  = options;
     _logger   = logger;
 }
Esempio n. 8
0
		public MI_Record (IRecordStore store)
			: base ("record", false)
		{
			if (store == null) {
				throw new ArgumentNullException ("store");
			}

			_Store = store;

			HelpText = ""
				+ Selector + " name\n"
				+ "Records all subsequent commands to the specified file name.\n"
				+ "Recording can be stopped by the command \"" + EndRecordCommand + "\"\n"
				+ "Stored records can be played via the \"replay\" command.\n"
				+ "\n"
				+ "Nested recording is not supported.";
			PromptCharacter = "record>";

			Add (EndRecordCommand, s => Quit (), "Finishes recording.");
			Add (null, s => _Lines.Add (s));
		}
Esempio n. 9
0
        public MI_Record(IRecordStore store)
            : base("record", false)
        {
            if (store == null)
            {
                throw new ArgumentNullException("store");
            }

            _Store = store;

            HelpText = ""
                       + Selector + " name\n"
                       + "Records all subsequent commands to the specified file name.\n"
                       + "Recording can be stopped by the command \"" + EndRecordCommand + "\"\n"
                       + "Stored records can be played via the \"replay\" command.\n"
                       + "\n"
                       + "Nested recording is not supported.";
            PromptCharacter = "record>";

            Add(EndRecordCommand, s => Quit(), "Finishes recording.");
            Add(null, s => _Lines.Add(s));
        }
Esempio n. 10
0
 public Task RebuildAsync(IRecordStore store, CancellationToken cancellationToken = default)
 {
     return(Task.CompletedTask);
 }
Esempio n. 11
0
        public static async Task OnRecordAddedAsync(this IEnumerable <IRecordEventHandler> handlers, IRecordStore store,
                                                    Record record, CancellationToken cancellationToken = default)
        {
            var pending = TaskPool.Get();

            try
            {
                foreach (var handler in handlers)
                {
                    var task = handler.OnRecordAddedAsync(store, record, cancellationToken);
                    if (!task.IsReal())
                    {
                        continue;
                    }

                    if (task.IsCompleted || task.IsCanceled || task.IsFaulted)
                    {
                        continue;
                    }

                    pending.Add(task);
                }

                if (pending.Count > 0)
                {
                    await Task.WhenAll(pending);
                }
            }
            finally
            {
                TaskPool.Return(pending);
            }
        }
 public override Task OnRecordAddedAsync(IRecordStore store, Record record,
                                         CancellationToken cancellationToken = default)
 {
     return(Task.Run(() => _cache.Clear(), cancellationToken));
 }
Esempio n. 13
0
        public static async Task OnRecordsInitAsync(this IEnumerable <IRecordEventHandler> handlers, IRecordStore store,
                                                    CancellationToken cancellationToken = default)
        {
            var pending = TaskPool.Get();

            try
            {
                foreach (var handler in handlers)
                {
                    var task = handler.OnRecordsInitAsync(store, cancellationToken);

                    if (!task.IsReal())
                    {
                        continue; // returns AsyncExtensions.NoTask
                    }
                    if (task.IsCompleted || task.IsCanceled || task.IsFaulted)
                    {
                        continue; // task is already terminal since being instantiated
                    }
                    pending.Add(task);
                }

                if (pending.Count > 0)
                {
                    await Task.WhenAll(pending);
                }
            }
            finally
            {
                TaskPool.Return(pending);
            }
        }
Esempio n. 14
0
 public Task OnRecordsInitAsync(IRecordStore store, CancellationToken cancellationToken = default)
 {
     return(AsyncExtensions.NoTask);
 }
Esempio n. 15
0
 public abstract Task OnRecordAddedAsync(IRecordStore store, Record record,
                                         CancellationToken cancellationToken = default);
Esempio n. 16
0
 public virtual Task Configure(IRecordStore <T> store)
 {
     this.store = store;
     return(null);
 }
Esempio n. 17
0
 public Task OnRecordAddedAsync(IRecordStore store, Record record, CancellationToken cancellationToken = default)
 {
     return(_index.RebuildAsync(store, cancellationToken));
 }
Esempio n. 18
0
 public Task OnInitAsync(IRecordStore store, CancellationToken cancellationToken = default)
 {
     return(_listeners.OnRecordsInitAsync(store, cancellationToken));
 }
Esempio n. 19
0
 public Task OnAddedAsync(IRecordStore store, Record record, CancellationToken cancellationToken = default)
 {
     return(_listeners.OnRecordAddedAsync(store, record, cancellationToken));
 }
Esempio n. 20
0
 public DataSource(Adapter <T> adapter = null, IRecordStore <T> store = null)
 {
     this.adapter     = adapter ?? new Adapter <T>();
     this.recordStore = store ?? new ListRecordStore <T>();
     this.config      = this.adapter.Configure(recordStore);
 }
Esempio n. 21
0
 public virtual void SetStore(IRecordStore <T> store)
 {
     this.store = store;
 }