static public EventHandler GetEventHandler(this FunctionSyncro item, Predicate <EventArgs> predicate) { if (item.GetFunction().HasNoParameters()) { return(delegate(object sender, EventArgs e) { if (predicate(e)) { item.Execute(); } }); } if (item.GetFunction().GetNumberParameters() == 1) { return(delegate(object sender, EventArgs e) { if (predicate(e)) { item.Execute(new object[] { e }); } }); } if (item.GetFunction().GetNumberParameters() == 2) { return(delegate(object sender, EventArgs e) { if (predicate(e)) { item.Execute(new object[] { sender, e }); } }); } throw new UnexpectedSignatureException(item.GetFunction().GetParameterTypes()); }
private bool PushToRepresentationInternal(CmlValue_Function value, object representation, CmlContext context) { FunctionSyncro function_syncro = new FunctionSyncro(value.GetFunctionInstance()); context.AddFunctionSyncro(function_syncro); hook.AddDelegate(representation, function_syncro.CreateDelegate(hook.GetHookType())); return(true); }
private bool PushToRepresentationInternal(CmlValue_Function value, object representation, CmlContext context) { REPRESENTATION_TYPE cast; FunctionSyncro function_syncro = new FunctionSyncro(value.GetFunctionInstance()); context.AddFunctionSyncro(function_syncro); if (representation.Convert <REPRESENTATION_TYPE>(out cast)) { ApplyFunctionSyncroToRepresentation(cast, function_syncro); } return(true); }
protected abstract void ApplyFunctionSyncroToRepresentation(REPRESENTATION_TYPE representation, FunctionSyncro function_syncro);
protected override void ApplyFunctionSyncroToRepresentation(REPRESENTATION_TYPE representation, FunctionSyncro function_syncro) { process(representation, function_syncro); }
static public T CreateDelegate <T>(this FunctionSyncro item) { return(item.CreateDelegate(typeof(T)).Convert <T>()); }
static public Delegate CreateDelegate(this FunctionSyncro item, Type delegate_type) { return(GET_INSTANCER .Fetch(delegate_type, new ContentsEnumerable <Type>(item.GetFunction().GetParameterTypes()))(item)); }
static public EventHandler GetEventHandler(this FunctionSyncro item) { return(item.GetEventHandler(e => true)); }
static public void AddFunctionSyncro(this CmlContext item, FunctionSyncro function_syncro) { function_syncro.SetManager(item.GetSyncroManager()); }