Skip to content

Commit 89a33a3

Browse files
committed
feat: implement TryDeserialize and CreateInstance in EventData converter
1 parent df165d5 commit 89a33a3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Scripts/Services/Discovery/v1/Models/EventData.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*
1616
*/
1717
using FullSerializer;
18+
using FullSerializer.Internal;
1819
using System;
1920
using System.Collections.Generic;
2021

@@ -75,12 +76,22 @@ public override bool CanProcess(Type type)
7576

7677
public override object CreateInstance(fsData data, Type storageType)
7778
{
78-
return base.CreateInstance(data, storageType);
79+
return new EventData();
7980
}
8081

8182
public override fsResult TryDeserialize(fsData data, ref object instance, Type storageType)
8283
{
83-
throw new NotImplementedException();
84+
if (data.IsString == false)
85+
{
86+
return fsResult.Fail("Type converter requires a string");
87+
}
88+
89+
instance = fsTypeCache.GetType(data.AsString);
90+
if (instance == null)
91+
{
92+
return fsResult.Fail("Unable to find type " + data.AsString);
93+
}
94+
return fsResult.Success;
8495
}
8596

8697
public override fsResult TrySerialize(object instance, out fsData serialized, Type storageType)

0 commit comments

Comments
 (0)