Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlDownloadManager.cs
Go to the documentation of this file.
1
using
System.IO
;
2
using
System.Net
;
3
using
System.Net.Http
;
4
using
System.Threading.Tasks
;
5
6
namespace
System.Xml
;
7
8
internal
sealed
class
XmlDownloadManager
9
{
10
internal
Stream
GetStream
(
Uri
uri,
ICredentials
credentials
,
IWebProxy
proxy
)
11
{
12
if
(uri.
Scheme
==
"file"
)
13
{
14
return
new
FileStream
(uri.
LocalPath
,
FileMode
.Open,
FileAccess
.Read,
FileShare
.Read, 1);
15
}
16
return
GetNonFileStreamAsync
(uri,
credentials
,
proxy
).GetAwaiter().GetResult();
17
}
18
19
internal
Task<Stream>
GetStreamAsync
(
Uri
uri,
ICredentials
credentials
,
IWebProxy
proxy
)
20
{
21
if
(uri.
Scheme
==
"file"
)
22
{
23
Uri
fileUri
= uri;
24
return
Task
.
Run
((
Func<Stream>
)(() =>
new
FileStream
(
fileUri
.LocalPath,
FileMode
.Open,
FileAccess
.Read,
FileShare
.Read, 1, useAsync:
true
)));
25
}
26
return
GetNonFileStreamAsync
(uri,
credentials
,
proxy
);
27
}
28
29
private
async
Task<Stream>
GetNonFileStreamAsync
(
Uri
uri,
ICredentials
credentials
,
IWebProxy
proxy
)
30
{
31
HttpClientHandler
httpClientHandler
=
new
HttpClientHandler
();
32
using
HttpClient
client
=
new
HttpClient
(
httpClientHandler
);
33
if
(
credentials
!=
null
)
34
{
35
httpClientHandler.Credentials
=
credentials
;
36
}
37
if
(
proxy
!=
null
)
38
{
39
httpClientHandler.Proxy
=
proxy
;
40
}
41
using
Stream
stream
=
await
client
.GetStreamAsync(uri).ConfigureAwait(
continueOnCapturedContext
:
false
);
42
MemoryStream
memoryStream
=
new
MemoryStream
();
43
stream
.CopyTo(
memoryStream
);
44
memoryStream.Position
= 0
L
;
45
return
memoryStream
;
46
}
47
}
System.IO.FileStream
Definition
FileStream.cs:11
System.IO.MemoryStream
Definition
MemoryStream.cs:9
System.IO.Stream
Definition
Stream.cs:11
System.Net.Http.HttpClientHandler
Definition
HttpClientHandler.cs:13
System.Net.Http.HttpClient
Definition
HttpClient.cs:12
System.Threading.Tasks.Task.Run
static Task Run(Action action)
Definition
Task.cs:3395
System.Threading.Tasks.Task
Definition
Task.cs:14
System.Uri.Scheme
string Scheme
Definition
Uri.cs:505
System.Uri.LocalPath
string LocalPath
Definition
Uri.cs:280
System.Uri
Definition
Uri.cs:16
System.Xml.XmlDownloadManager.GetStreamAsync
Task< Stream > GetStreamAsync(Uri uri, ICredentials credentials, IWebProxy proxy)
Definition
XmlDownloadManager.cs:19
System.Xml.XmlDownloadManager.GetStream
Stream GetStream(Uri uri, ICredentials credentials, IWebProxy proxy)
Definition
XmlDownloadManager.cs:10
System.Xml.XmlDownloadManager.GetNonFileStreamAsync
async Task< Stream > GetNonFileStreamAsync(Uri uri, ICredentials credentials, IWebProxy proxy)
Definition
XmlDownloadManager.cs:29
System.Xml.XmlDownloadManager
Definition
XmlDownloadManager.cs:9
System.Net.ICredentials
Definition
ICredentials.cs:4
System.Net.IWebProxy
Definition
IWebProxy.cs:4
System.IO.FileAccess
FileAccess
Definition
FileAccess.cs:5
System.IO.FileShare
FileShare
Definition
FileShare.cs:5
System.IO.FileMode
FileMode
Definition
FileMode.cs:4
System.IO
Definition
ConsoleStream.cs:3
System.Net.Http
Definition
HttpClientJsonExtensions.cs:8
System.Net
Definition
HttpClientJsonExtensions.cs:8
System.Threading.Tasks
Definition
TaskToApm.cs:3
System.Xml.PrefixHandleType.L
@ L
System.Xml.ValueHandleType.Dictionary
@ Dictionary
System.Xml
Definition
BaseRegionIterator.cs:1
System.ExceptionArgument.stream
@ stream
source
System.Private.Xml
System.Xml
XmlDownloadManager.cs
Generated by
1.10.0