-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathConverter2.cs
More file actions
33 lines (27 loc) · 768 Bytes
/
Converter2.cs
File metadata and controls
33 lines (27 loc) · 768 Bytes
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
using System;
using System.Text;
using System.Threading.Tasks;
using Waher.Content;
using Waher.Runtime.Inventory;
namespace Waher.Networking.HTTP.Test
{
public class Converter2 : IContentConverter
{
public Converter2()
{
}
public string[] FromContentTypes => ["text/x-test1"];
public string[] ToContentTypes => ["text/x-test2"];
public Grade ConversionGrade => Grade.Ok;
public async Task<bool> ConvertAsync(ConversionState State)
{
byte[] Data = new byte[State.From.Length];
await State.From.ReadAsync(Data, 0, (int)State.From.Length);
string s = Encoding.UTF8.GetString(Data);
s += "\r\nConverter 2 was here.";
Data = Encoding.UTF8.GetBytes(s);
await State.To.WriteAsync(Data, 0, Data.Length);
return false;
}
}
}