/// <summary> /// 执行自定义的操作,返回REST结果集 /// </summary> /// <typeparam name="TEntity">要操作的数据实体对象的类型</typeparam> /// <typeparam name="TReturn">要返回的数据类型</typeparam> /// <param name="changeFunc">自定义写入操作,该参数是一个委托</param> /// <param name="entity">要写入的数据实体对象</param> /// <returns>返回处理后的REST结果集</returns> public virtual Result <TReturn> Execute <TEntity, TReturn>(ChangeHandler <TContext, TEntity, TReturn> changeFunc, TEntity entity) where TEntity : class { this.SetHttpStatusCodeOK(); Result <TReturn> result = CreateResult <TReturn>(); try { TContext context = this.EntityContext; if (changeFunc != null) { result.Results = changeFunc.Invoke(context, entity); } } catch (Exception ex) { result.UpdateToError(ex.Message); } finally { if (this._context != null) { this._context.Dispose(); } } return(result); }
private void SteamVR_Behaviour_Pose_OnChange(SteamVR_Action_Pose fromAction, SteamVR_Input_Sources fromSource) { if (onTransformChanged != null) { onTransformChanged.Invoke(this, fromSource); } if (onTransformChangedEvent != null) { onTransformChangedEvent.Invoke(this, fromSource); } }
private void SteamVR_Behaviour_Vector3_OnChange(SteamVR_Action_Vector3 fromAction, SteamVR_Input_Sources fromSource, Vector3 newAxis, Vector3 newDelta) { if (onChange != null) { onChange.Invoke(this, fromSource, newAxis, newDelta); } if (onChangeEvent != null) { onChangeEvent.Invoke(this, fromSource, newAxis, newDelta); } }
private void SteamVR_Behaviour_Single_OnChange(SteamVR_Action_Single fromAction, SteamVR_Input_Sources fromSource, float newAxis, float newDelta) { if (onChange != null) { onChange.Invoke(this, fromSource, newAxis, newDelta); } if (onChangeEvent != null) { onChangeEvent.Invoke(this, fromSource, newAxis, newDelta); } }
private static void HandleSimplifier(List <Element> decodedEquation) { output?.Invoke(decodedEquation); try { Simplifier simplifier = new Simplifier(decodedEquation, output); Number result = simplifier.Simplify(); Console.WriteLine(result.ToString()); } catch (WrongSolverChoosenException e) { Console.WriteLine(e.Message); } }
public void UserSelected(int index) { string color1 = color[index]; // 调用回调的方法。。。 if (handler != null) { handler.Invoke(color1); } }
protected virtual void UpdatePose() { if (skeletonAction == null) { return; } Vector3 skeletonPosition = skeletonAction.GetLocalPosition(); Quaternion skeletonRotation = skeletonAction.GetLocalRotation(); if (origin == null) { if (this.transform.parent != null) { skeletonPosition = this.transform.parent.TransformPoint(skeletonPosition); skeletonRotation = this.transform.parent.rotation * skeletonRotation; } } else { skeletonPosition = origin.TransformPoint(skeletonPosition); skeletonRotation = origin.rotation * skeletonRotation; } if (skeletonAction.poseChanged) { if (onTransformChanged != null) { onTransformChanged.Invoke(this, inputSource); } if (onTransformChangedEvent != null) { onTransformChangedEvent.Invoke(this, inputSource); } } this.transform.position = skeletonPosition; this.transform.rotation = skeletonRotation; if (onTransformUpdated != null) { onTransformUpdated.Invoke(this, inputSource); } }
static void Main(string[] args) { ProductList prods = new ProductList(); prods.Add("jse6", "A new Book", 100m); prods.Add("Chachamim", "Another Book", 200m); // מצהירה על אוביקט מטיפוס הדלגט //create the delegate and identify its method: ChangeHandler myDelegate; // מאתחלת אותו עם פונקציה המתאימה לטיפוס הדלגט myDelegate = new ChangeHandler(ProductList.PrintToConsole); //הפעלה של כל המתודות הרשומות לדלגט myDelegate(prods); Console.WriteLine("after first calling"); myDelegate += printCount; myDelegate.Invoke(prods); }
public void OutputChange() { output?.Invoke(input); }
private void OnValueChanged(EventArgs e) { ChangeHandler?.Invoke(this, e); }