况洋洋
2025-07-04 0d247bd2a17e0f99f3609774a1ce54ae00857997
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright © 2021 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
 
using System.IO;
 
namespace CefSharp.Fluent
{
    /// <summary>
    /// Fluent UrlRequestClient Builder
    /// </summary>
    public class UrlRequestClientBuilder
    {
        private UrlRequestClient client = new UrlRequestClient();
 
        /// <summary>
        /// See <see cref="IUrlRequestClient.GetAuthCredentials(bool, string, int, string, string, IAuthCallback)"/> for details
        /// </summary>
        /// <param name="func">function to be executed when <see cref="IUrlRequestClient.GetAuthCredentials(bool, string, int, string, string, IAuthCallback)"/>
        /// is called </param>
        /// <returns>
        /// Fluent Builder, call <see cref="UrlRequestClientBuilder.Build"/> to create
        /// a new <see cref="IUrlRequestClient"/> instance
        /// </returns>
        public UrlRequestClientBuilder GetAuthCredentials(GetAuthCredentialsDelegate func)
        {
            client.SetGetAuthCredentials(func);
 
            return this;
        }
 
        /// <summary>
        /// See <see cref="IUrlRequestClient.OnDownloadData(IUrlRequest, Stream)"/> for details.
        /// </summary>
        /// <param name="action">Action to be executed when <see cref="IUrlRequestClient.OnDownloadData(IUrlRequest, Stream)"/>
        /// is called</param>
        /// <returns>
        /// Fluent Builder, call <see cref="UrlRequestClientBuilder.Build"/> to create
        /// a new <see cref="IUrlRequestClient"/> instance
        /// </returns>
        public UrlRequestClientBuilder OnDownloadData(OnDownloadDataDelegate action)
        {
            client.SetOnDownloadData(action);
 
            return this;
        }
 
        /// <summary>
        /// See <see cref="IUrlRequestClient.OnDownloadProgress(IUrlRequest, long, long)"/> for details.
        /// </summary>
        /// <param name="action">Action to be executed when <see cref="IUrlRequestClient.OnDownloadProgress(IUrlRequest, long, long)"/>
        /// is called</param>
        /// <returns>
        /// Fluent Builder, call <see cref="UrlRequestClientBuilder.Build"/> to create
        /// a new <see cref="IUrlRequestClient"/> instance
        /// </returns>
        public UrlRequestClientBuilder OnDownloadProgress(OnDownloadProgressDelegate action)
        {
            client.SetOnDownloadProgress(action);
 
            return this;
        }
 
        /// <summary>
        /// See <see cref="IUrlRequestClient.OnRequestComplete"/> for details.
        /// </summary>
        /// <param name="action">Action to be executed when <see cref="IUrlRequestClient.OnRequestComplete(IUrlRequest)"/>
        /// is called</param>
        /// <returns>
        /// Fluent Builder, call <see cref="UrlRequestClientBuilder.Build"/> to create
        /// a new <see cref="IUrlRequestClient"/> instance
        /// </returns>
        public UrlRequestClientBuilder OnRequestComplete(OnRequestCompleteDelegate action)
        {
            client.SetOnRequestComplete(action);
 
            return this;
        }
 
        /// <summary>
        /// See <see cref="IUrlRequestClient.OnUploadProgress(IUrlRequest, long, long)"/> for details.
        /// </summary>
        /// <param name="action">Action to be executed when <see cref="IUrlRequestClient.OnUploadProgress(IUrlRequest, long, long)"/>
        /// is called</param>
        /// <returns>
        /// Fluent Builder, call <see cref="UrlRequestClientBuilder.Build"/> to create
        /// a new <see cref="IUrlRequestClient"/> instance
        /// </returns>
        public UrlRequestClientBuilder OnUploadProgress(OnUploadProgressDelegate action)
        {
            client.SetOnUploadProgress(action);
 
            return this;
        }
 
        /// <summary>
        /// Create a <see cref="IUrlRequestClient"/> instance
        /// </summary>
        /// <returns> a <see cref="IUrlRequestClient"/> instance</returns>
        public IUrlRequestClient Build()
        {
            return client;
        }
    }
}