public IAsyncResult BeginInvoke(Delegate method, object[] args) { GeneralDelegate x = Invoke; return(x.BeginInvoke(method, args, null, x)); }
public void RemoveGD(int id, GeneralDelegate <T> gd) { if (!this.HasType(id)) { return; } this._GDCntr[id] -= gd; }
public void AddGD(int id, GeneralDelegate <T> gd) { if (!this.HasType(id)) { GeneralDelegate <T> generalDelegate = (GeneralDelegate <T>)null; this._GDCntr[id] = generalDelegate; } this._GDCntr[id] += gd; }
public void TestDelegateCast() { SpecializedDelegate specializedDelegate = new SpecializedDelegate(this.SpecializedDelegateMethod); GeneralDelegate generalDelegate = DuckTyping.Cast<GeneralDelegate>(specializedDelegate); Assert.IsTrue(generalDelegate.Target is IDuckProxy, "Cast did not return a delegate to a proxy."); Assert.AreEqual(specializedDelegate, ((IDuckProxy)(generalDelegate.Target)).UnwrapDuck(), "Cast returned a delegate to a proxy that does not refer to the original delegate."); Assert.AreEqual(specializedDelegate, DuckTyping.Cast<SpecializedDelegate>(generalDelegate), "Reverse cast returned the wrong value."); bool b = (bool)(generalDelegate("true")); generalDelegate = new GeneralDelegate(this.GeneralDelegateMethod); specializedDelegate = DuckTyping.Cast<SpecializedDelegate>(generalDelegate); Assert.IsTrue(specializedDelegate.Target is IDuckProxy, "Cast did not return a delegate to a proxy."); Assert.AreEqual(generalDelegate, ((IDuckProxy)(specializedDelegate.Target)).UnwrapDuck(), "Cast returned a delegate to a proxy that does not refer to the original delegate."); Assert.AreEqual(generalDelegate, DuckTyping.Cast<GeneralDelegate>(specializedDelegate), "Reverse cast returned the wrong value."); specializedDelegate("true"); }
public void TestDelegateCast() { SpecializedDelegate specializedDelegate = new SpecializedDelegate(this.SpecializedDelegateMethod); GeneralDelegate generalDelegate = DuckTyping.Cast <GeneralDelegate>(specializedDelegate); Assert.IsTrue(generalDelegate.Target is IDuckProxy, "Cast did not return a delegate to a proxy."); Assert.AreEqual(specializedDelegate, ((IDuckProxy)(generalDelegate.Target)).UnwrapDuck(), "Cast returned a delegate to a proxy that does not refer to the original delegate."); Assert.AreEqual(specializedDelegate, DuckTyping.Cast <SpecializedDelegate>(generalDelegate), "Reverse cast returned the wrong value."); bool b = (bool)(generalDelegate("true")); generalDelegate = new GeneralDelegate(this.GeneralDelegateMethod); specializedDelegate = DuckTyping.Cast <SpecializedDelegate>(generalDelegate); Assert.IsTrue(specializedDelegate.Target is IDuckProxy, "Cast did not return a delegate to a proxy."); Assert.AreEqual(generalDelegate, ((IDuckProxy)(specializedDelegate.Target)).UnwrapDuck(), "Cast returned a delegate to a proxy that does not refer to the original delegate."); Assert.AreEqual(generalDelegate, DuckTyping.Cast <GeneralDelegate>(specializedDelegate), "Reverse cast returned the wrong value."); specializedDelegate("true"); }
public object EndInvoke(IAsyncResult result) { GeneralDelegate x = (GeneralDelegate)result.AsyncState; return(x.EndInvoke(result)); }