AcManager.Tools.ContentInstallation.BaseContentInstallator.InstallEntryToAsync C# (CSharp) Method

InstallEntryToAsync() public method

public InstallEntryToAsync ( ContentEntry entry, bool>.Func filter, string destination, IProgress progress, CancellationToken cancellation ) : Task
entry ContentEntry
filter bool>.Func
destination string
progress IProgress
cancellation System.Threading.CancellationToken
return Task
        public virtual async Task InstallEntryToAsync(ContentEntry entry, Func<string, bool> filter, string destination,
                IProgress<string> progress, CancellationToken cancellation) {
            var list = (await GetFileEntriesAsync()).ToList();

            if (entry.Type == ContentType.Car ||
                    entry.Type == ContentType.Track ||
                    entry.Type == ContentType.Showroom) {
                foreach (var fileInfo in list) {
                    var filename = fileInfo.Filename;
                    if (entry.Path != string.Empty && !FileUtils.IsAffected(entry.Path, filename)) continue;

                    var subFilename = filename.SubstringExt(entry.Path.Length);
                    if (subFilename.StartsWith(@"\")) subFilename = subFilename.Substring(1);

                    if (filter == null || filter(subFilename)) {
                        progress?.Report(subFilename);
                        if (cancellation.IsCancellationRequested) return;

                        var path = Path.Combine(destination, subFilename);
                        Directory.CreateDirectory(Path.GetDirectoryName(path) ?? destination);

                        await fileInfo.CopyTo(path);
                    }
                }
            } else if (entry.Type == ContentType.CarSkin) {
                
            } else if (entry.Type == ContentType.Font) {
                var bitmapExtension = Path.GetExtension(entry.Path);

                var mainEntry = list.GetByPathOrDefault(entry.Path.ApartFromLast(bitmapExtension) + FontObject.FontExtension);
                await mainEntry.CopyTo(destination);

                var bitmapDestination = destination.ApartFromLast(FontObject.FontExtension) + bitmapExtension;
                await list.GetByPathOrDefault(entry.Path).CopyTo(bitmapDestination);
            } else {
                throw new ArgumentOutOfRangeException();
            }
        }
    }