Skip to content

Commit 7c38d4c

Browse files
committed
add NetDataReader.Get<T>(out...)
1 parent 4c2e7b1 commit 7c38d4c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

LiteNetLib/Utils/NetDataReader.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ public NetDataReader(byte[] source, int offset, int maxSize)
108108

109109
#region GetMethods
110110

111+
public void Get<T>(out T result) where T : struct, INetSerializable
112+
{
113+
result = default(T);
114+
result.Deserialize(this);
115+
}
116+
117+
public void Get<T>(out T result, Func<T> constructor) where T : class, INetSerializable
118+
{
119+
result = constructor();
120+
result.Deserialize(this);
121+
}
122+
111123
public void Get(out IPEndPoint result)
112124
{
113125
result = GetNetEndPoint();

0 commit comments

Comments
 (0)