예제 #1
0
        /// <summary>
        /// lock descriptors as an asynchronous operation.
        /// </summary>
        /// <param name="mods">The mods.</param>
        /// <param name="isLocked">if set to <c>true</c> [is locked].</param>
        /// <returns>Task&lt;System.Boolean&gt;.</returns>
        public virtual async Task <bool> LockDescriptorsAsync(IEnumerable <IMod> mods, bool isLocked)
        {
            var game = GameService.GetSelected();

            if (game != null && mods?.Count() > 0)
            {
                var tasks = new List <Task>();
                foreach (var item in mods)
                {
                    // Cannot lock\unlock mandatory local zipped mods
                    if (!CheckIfModShouldBeLocked(game, item))
                    {
                        var task = ModWriter.SetDescriptorLockAsync(new ModWriterParameters()
                        {
                            Mod           = item,
                            RootDirectory = game.UserDirectory
                        }, isLocked);
                        item.IsLocked = isLocked;
                        tasks.Add(task);
                    }
                }
                await Task.WhenAll(tasks);

                return(true);
            }
            return(false);
        }
예제 #2
0
        /// <summary>
        /// lock descriptors as an asynchronous operation.
        /// </summary>
        /// <param name="mods">The mods.</param>
        /// <param name="isLocked">if set to <c>true</c> [is locked].</param>
        /// <returns>Task&lt;System.Boolean&gt;.</returns>
        public virtual async Task <bool> LockDescriptorsAsync(IEnumerable <IMod> mods, bool isLocked)
        {
            var game = GameService.GetSelected();

            if (game != null && mods?.Count() > 0)
            {
                var tasks = new List <Task>();
                foreach (var item in mods)
                {
                    var task = ModWriter.SetDescriptorLockAsync(new ModWriterParameters()
                    {
                        Mod           = item,
                        RootDirectory = game.UserDirectory
                    }, isLocked);
                    tasks.Add(task);
                }
                await Task.WhenAll(tasks);

                return(true);
            }
            return(false);
        }