mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Simplify guard check
This commit is contained in:
parent
65f6e42b53
commit
ca418457e8
@ -64,33 +64,18 @@ public static bool HasServerClientAttribute(MethodDefinition md)
|
|||||||
|
|
||||||
public static bool ProcessMethodAttributes(TypeDefinition td, MethodDefinition md)
|
public static bool ProcessMethodAttributes(TypeDefinition td, MethodDefinition md)
|
||||||
{
|
{
|
||||||
bool modified = false;
|
if (md.HasCustomAttribute<Mirror.ServerAttribute>())
|
||||||
foreach (CustomAttribute attr in md.CustomAttributes)
|
|
||||||
{
|
|
||||||
switch (attr.Constructor.DeclaringType.ToString())
|
|
||||||
{
|
|
||||||
case "Mirror.ServerAttribute":
|
|
||||||
InjectServerGuard(md, true);
|
InjectServerGuard(md, true);
|
||||||
modified = true;
|
else if (md.HasCustomAttribute<Mirror.ServerCallbackAttribute>())
|
||||||
break;
|
|
||||||
case "Mirror.ServerCallbackAttribute":
|
|
||||||
InjectServerGuard(md, false);
|
InjectServerGuard(md, false);
|
||||||
modified = true;
|
else if (md.HasCustomAttribute<Mirror.ClientAttribute>())
|
||||||
break;
|
|
||||||
case "Mirror.ClientAttribute":
|
|
||||||
InjectClientGuard(md, true);
|
InjectClientGuard(md, true);
|
||||||
modified = true;
|
else if (md.HasCustomAttribute<Mirror.ClientCallbackAttribute>())
|
||||||
break;
|
|
||||||
case "Mirror.ClientCallbackAttribute":
|
|
||||||
InjectClientGuard(md, false);
|
InjectClientGuard(md, false);
|
||||||
modified = true;
|
else
|
||||||
break;
|
return false;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return modified;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InjectServerGuard(MethodDefinition md, bool logWarning)
|
static void InjectServerGuard(MethodDefinition md, bool logWarning)
|
||||||
|
Loading…
Reference in New Issue
Block a user