Beispiel #1
0
        public async Task SetCommandDataAsync(RegisteredCommandData commandData)
        {
            if (commandData == null)
            {
                throw new ArgumentNullException(nameof(commandData));
            }

            var commandsData = await GetRegisteredCommandsAsync();

            var commands = commandsData.Commands ?? new List <RegisteredCommandData>();

            var idx = commands.FindIndex(c =>
                                         c.Id?.Equals(commandData.Id, StringComparison.OrdinalIgnoreCase) ?? false);

            commands.RemoveAll(c =>
                               c.Id?.Equals(commandData.Id, StringComparison.OrdinalIgnoreCase) ?? false);

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

            commandsData.Commands = commands;
            m_Cache = commandsData;
            await m_DataStore.SaveAsync(CommandsKey, commandsData);
        }
Beispiel #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);
        }
Beispiel #3
0
 public RegisteredCommand(ICommandRegistration baseCommandRegistration, RegisteredCommandData commandData)
 {
     BaseCommandRegistration = baseCommandRegistration;
     CommandData             = commandData;
 }