3using System.Security.Cryptography.X509Certificates;
4using System.Threading.Tasks;
39 if (
string.IsNullOrEmpty(UriToResource(Uri)))
51 private static string UriToResource(Uri Uri)
55 switch (Uri.OriginalString)
57 case "urn:nf:iot:e2e:1.0":
58 SchemaName =
"E2E.xsd";
61 case "urn:nf:iot:leg:id:1.0":
62 SchemaName =
"LegalIdentities.xsd";
65 case "urn:nf:iot:p2p:1.0":
66 SchemaName =
"P2P.xsd";
69 case "urn:nf:iot:leg:sc:1.0":
70 SchemaName =
"SmartContracts.xsd";
77 return typeof(ContractsClient).Namespace +
".Schema." + SchemaName;
88 public Task<ContentResponse>
GetAsync(Uri Uri, X509Certificate Certificate, EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator,
89 params KeyValuePair<string, string>[] Headers)
91 string SchemaName = UriToResource(Uri);
92 if (
string.IsNullOrEmpty(SchemaName))
93 return Task.FromResult(
new ContentResponse(
new Exception(
"URI not recognized.")));
107 public Task<ContentResponse>
GetAsync(Uri Uri, X509Certificate Certificate, EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator,
108 int TimeoutMs, params KeyValuePair<string, string>[] Headers)
110 return this.
GetAsync(Uri, Certificate, RemoteCertificateValidator, Headers);
122 EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator, params KeyValuePair<string, string>[] Headers)
137 EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator,
TemporaryStream Destination, params KeyValuePair<string, string>[] Headers)
152 EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator,
int TimeoutMs, params KeyValuePair<string, string>[] Headers)
154 return this.
GetTempStreamAsync(Uri, Certificate, RemoteCertificateValidator, TimeoutMs,
null, Headers);
168 EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator,
int TimeoutMs,
TemporaryStream Destination,
169 params KeyValuePair<string, string>[] Headers)
171 string SchemaName = UriToResource(Uri);
172 if (
string.IsNullOrEmpty(SchemaName))
178 await Destination.
WriteAsync(Bin, 0, Bin.Length);
203 public Task<ContentResponse>
HeadAsync(Uri Uri, X509Certificate Certificate, EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator,
204 params KeyValuePair<string, string>[] Headers)
206 return this.
GetAsync(Uri, Certificate, RemoteCertificateValidator, Headers);
218 public Task<ContentResponse>
HeadAsync(Uri Uri, X509Certificate Certificate, EventHandler<RemoteCertificateEventArgs> RemoteCertificateValidator,
219 int TimeoutMs, params KeyValuePair<string, string>[] Headers)
221 return this.
GetAsync(Uri, Certificate, RemoteCertificateValidator, TimeoutMs, Headers);
Contains information about a response to a content request.
Contains information about a stream response to a content request.
Static class managing encoding and decoding of internet content.
static int DefaultTimeout
Default timeout of internet access methods, in milliseconds.
const string DefaultContentType
Default content type for XML documents.
const string SchemaContentType
Default content type for XML schema documents.
Static class managing loading of XSL resources stored as embedded resources or in content files.
static XmlSchema LoadSchema(string ResourceName)
Loads an XML schema from an embedded resource.
Getter for well-known contract schemas.
bool CanGet(Uri Uri, out Grade Grade)
If the getter is able to get a resource, given its URI.
string[] UriSchemes
Supported URI schemes.
Task< ContentResponse > HeadAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, params KeyValuePair< string, string >[] Headers)
Gets the headers of a resource, using a Uniform Resource Identifier (or Locator).
Task< ContentResponse > HeadAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, int TimeoutMs, params KeyValuePair< string, string >[] Headers)
Gets the headers of a resource, using a Uniform Resource Identifier (or Locator).
async Task< ContentStreamResponse > GetTempStreamAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, int TimeoutMs, TemporaryStream Destination, params KeyValuePair< string, string >[] Headers)
Gets a (possibly big) resource, using a Uniform Resource Identifier (or Locator).
Task< ContentResponse > GetAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, int TimeoutMs, params KeyValuePair< string, string >[] Headers)
Gets a resource, using a Uniform Resource Identifier (or Locator).
bool CanHead(Uri Uri, out Grade Grade)
If the getter is able to get headers of a resource, given its URI.
ContractSchemasGetter()
Getter for well-known contract schemas.
Task< ContentStreamResponse > GetTempStreamAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, int TimeoutMs, params KeyValuePair< string, string >[] Headers)
Gets a (possibly big) resource, using a Uniform Resource Identifier (or Locator).
Task< ContentResponse > GetAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, params KeyValuePair< string, string >[] Headers)
Gets a resource, using a Uniform Resource Identifier (or Locator).
Task< ContentStreamResponse > GetTempStreamAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, params KeyValuePair< string, string >[] Headers)
Gets a (possibly big) resource, using a Uniform Resource Identifier (or Locator).
Task< ContentStreamResponse > GetTempStreamAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, TemporaryStream Destination, params KeyValuePair< string, string >[] Headers)
Gets a (possibly big) resource, using a Uniform Resource Identifier (or Locator).
Static class managing loading of resources stored as embedded resources or in content files.
static byte[] LoadResource(string ResourceName)
Loads a resource from an embedded resource.
Manages a temporary stream. Contents is kept in-memory, if below a memory threshold,...
override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
Asynchronously writes a sequence of bytes to the current stream, advances the current position within...
Basic interface for Internet Content getters. A class implementing this interface and having a defaul...