-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTestStructExpose.cs
More file actions
28 lines (25 loc) · 924 Bytes
/
TestStructExpose.cs
File metadata and controls
28 lines (25 loc) · 924 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
namespace Nahoum.UnityJSInterop.Tests
{
[ExposeWebSerialization(typeof(TsSerializerTestStructExpose))]
public struct TestStructExpose
{
public int A;
public float F;
public string Name;
[ExposeWeb]
public static TestStructExpose GetExposeInstance()
{
return new TestStructExpose
{
A = SampleValues.TestInt,
F = SampleValues.TestFloat,
Name = SampleValues.TestString
};
}
}
public class TsSerializerTestStructExpose : DefaultTypescriptSerializer<TestStructExpose>
{
protected override string GetTsTypeDefinition() => "{A: number, F: number, Name: string}";
protected override string SerializeToJavascript(TestStructExpose targetObject) => $"{{\"A\": {targetObject.A} , \"F\": {targetObject.F}, \"Name\": \"{targetObject.Name}\"}}";
}
}