1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-18 08:06:33 +09:00

Changed how ReadAllFields determines available write methods

This commit is contained in:
lidgren
2012-05-26 08:32:32 +00:00
parent 35a0831a83
commit 0fadd32a74

View File

@@ -6,7 +6,7 @@ namespace Lidgren.Network
{ {
public partial class NetBuffer public partial class NetBuffer
{ {
private const int c_overAllocateAmount = 4; protected const int c_overAllocateAmount = 4;
private static readonly Dictionary<Type, MethodInfo> s_readMethods; private static readonly Dictionary<Type, MethodInfo> s_readMethods;
private static readonly Dictionary<Type, MethodInfo> s_writeMethods; private static readonly Dictionary<Type, MethodInfo> s_writeMethods;
@@ -75,14 +75,9 @@ namespace Lidgren.Network
MethodInfo[] methods = typeof(NetIncomingMessage).GetMethods(BindingFlags.Instance | BindingFlags.Public); MethodInfo[] methods = typeof(NetIncomingMessage).GetMethods(BindingFlags.Instance | BindingFlags.Public);
foreach (MethodInfo mi in methods) foreach (MethodInfo mi in methods)
{ {
if (mi.GetParameters().Length == 0 && mi.Name.StartsWith("Read", StringComparison.InvariantCulture)) if (mi.GetParameters().Length == 0 && mi.Name.StartsWith("Read", StringComparison.InvariantCulture) && mi.Name.Substring(4) == mi.ReturnType.Name)
{ {
string n = mi.Name.Substring(4); s_readMethods[mi.ReturnType] = mi;
foreach (Type it in integralTypes)
{
if (it.Name == n)
s_readMethods[it] = mi;
}
} }
} }