public override bool Equals(object o) { if (o == null) { return(func == null && self == null); } LuaDelegate ld = o as LuaDelegate; if (ld == null || ld.func != func || ld.self != self) { return(false); } return(ld.func != null); }
private static bool CompareLuaDelegate(LuaDelegate a, LuaDelegate b) { if (object.ReferenceEquals(a, b)) { return(true); } if (a == null && b != null) { return(b.func == null && b.self == null); } if (a != null && b == null) { return(a.func == null && b.self == null); } return(!(a.func != b.func) && !(a.self != b.self) && a.func != null); }
static public Delegate Create(LuaFunction func) { if (func != null) { LuaState luaState = func.GetLuaState(); // 是否有保存 LuaDelegate luaDelegate = luaState.GetLuaDelegate(func); if (luaDelegate != null) { return(Delegate.CreateDelegate(typeof(T), luaDelegate, luaDelegate.method)); } Delegate d = _Create(func, null, false); luaDelegate = d.Target as LuaDelegate; luaDelegate.method = d.Method; luaState.AddLuaDelegate(luaDelegate, func); return(d); } return(_Create(null, null, false)); }
public static bool operator !=(LuaDelegate a, LuaDelegate b) { return(!LuaDelegate.CompareLuaDelegate(a, b)); }