Exemple #1
0
        public async Task <RegisteredCommandsData> GetRegisteredCommandsAsync()
        {
            if (m_Cache != null)
            {
                return(m_Cache);
            }

            m_Cache = await LoadCommandsFromDisk();

            m_ChangeWatcher = m_DataStore.AddChangeWatcher(CommandsKey, m_Runtime, () => m_Cache = AsyncHelper.RunSync(LoadCommandsFromDisk));
            return(m_Cache);
        }
Exemple #2
0
        public async Task SetCommandDataAsync(RegisteredCommandData commandData)
        {
            var commandsData = await GetRegisteredCommandsAsync();

            var idx = commandsData.Commands.FindIndex(c =>
                                                      c.Id.Equals(commandData.Id, StringComparison.OrdinalIgnoreCase));

            commandsData.Commands.RemoveAll(c =>
                                            c.Id.Equals(commandData.Id, StringComparison.OrdinalIgnoreCase));

            // preserve location in data
            if (idx >= 0)
            {
                commandsData.Commands.Insert(idx, commandData);
            }
            else
            {
                commandsData.Commands.Add(commandData);
            }

            m_Cache = commandsData;
            await m_DataStore.SaveAsync(CommandsKey, commandsData);
        }
Exemple #3
0
 public Task SetRegisteredCommandsAsync(RegisteredCommandsData data)
 {
     m_Cache = data;
     return(m_DataStore.SaveAsync(CommandsKey, data));
 }
 public Task SetRegisteredCommandsAsync(RegisteredCommandsData data)
 {
     m_Cache = data ?? throw new ArgumentNullException(nameof(data));
     return(m_DataStore.SaveAsync(CommandsKey, data));
 }