static void Main(string[] args) { IDataObject dtObj = DataObject.CreateDataObjec2(10, 6); int result = dtObj.Compute(); Console.ReadLine(); }
/// <summary> /// 拦截对 Compute 方法的调用; /// </summary> /// <returns></returns> public int Compute() { DoSomethingBeforeCompute(); int result = _realObject.Compute(); DoSomethingAfterCompute(result); return(result); }