コード例 #1
0
        public static async Task <LockFile> ReadWithLock(this LockFileFormat subject, string path)
        {
            return(await ConcurrencyUtilities.ExecuteWithFileLockedAsync(
                       path,
                       lockedToken =>
            {
                var lockFile = FileAccessRetrier.RetryOnFileAccessFailure(() => subject.Read(path));

                return lockFile;
            },
                       CancellationToken.None));
        }
コード例 #2
0
        public static async Task <LockFile> ReadWithLock(this LockFileFormat subject, string path)
        {
            return(await ConcurrencyUtilities.ExecuteWithFileLockedAsync(
                       path,
                       lockedToken =>
            {
                if (!File.Exists(path))
                {
                    throw new GracefulException(string.Join(
                                                    Environment.NewLine,
                                                    string.Format(Resources.GetString("FileNotFound"), path),
                                                    Resources.GetString("ProjectNotRestoredOrRestoreFailed")));
                }

                var lockFile = FileAccessRetrier.RetryOnFileAccessFailure(() => subject.Read(path), Resources.GetString("CouldNotAccessAssetsFile"));

                return lockFile;
            },
                       CancellationToken.None));
        }
コード例 #3
0
        public static async Task <LockFile> ReadWithLock(this LockFileFormat subject, string path)
        {
            if (!File.Exists(path))
            {
                throw new GracefulException(string.Join(
                                                Environment.NewLine,
                                                $"File not found `{path}`.",
                                                "The project may not have been restored or restore failed - run `dotnet restore`"));
            }

            return(await ConcurrencyUtilities.ExecuteWithFileLockedAsync(
                       path,
                       lockedToken =>
            {
                var lockFile = FileAccessRetrier.RetryOnFileAccessFailure(() => subject.Read(path));

                return lockFile;
            },
                       CancellationToken.None));
        }
コード例 #4
0
        public static async Task <LockFile> ReadWithLock(this LockFileFormat subject, string path)
        {
            if (!File.Exists(path))
            {
                throw new GracefulException(string.Join(
                                                Environment.NewLine,
                                                string.Format(LocalizableStrings.FileNotFound, path),
                                                LocalizableStrings.ProjectNotRestoredOrRestoreFailed));
            }

            return(await ConcurrencyUtilities.ExecuteWithFileLockedAsync(
                       path,
                       lockedToken =>
            {
                var lockFile = FileAccessRetrier.RetryOnFileAccessFailure(() => subject.Read(path));

                return lockFile;
            },
                       CancellationToken.None));
        }