예제 #1
0
        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());
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
 protected abstract void ApplyFunctionSyncroToRepresentation(REPRESENTATION_TYPE representation, FunctionSyncro function_syncro);
예제 #5
0
 protected override void ApplyFunctionSyncroToRepresentation(REPRESENTATION_TYPE representation, FunctionSyncro function_syncro)
 {
     process(representation, function_syncro);
 }
예제 #6
0
 static public T CreateDelegate <T>(this FunctionSyncro item)
 {
     return(item.CreateDelegate(typeof(T)).Convert <T>());
 }
예제 #7
0
 static public Delegate CreateDelegate(this FunctionSyncro item, Type delegate_type)
 {
     return(GET_INSTANCER
            .Fetch(delegate_type, new ContentsEnumerable <Type>(item.GetFunction().GetParameterTypes()))(item));
 }
예제 #8
0
 static public EventHandler GetEventHandler(this FunctionSyncro item)
 {
     return(item.GetEventHandler(e => true));
 }
예제 #9
0
 static public void AddFunctionSyncro(this CmlContext item, FunctionSyncro function_syncro)
 {
     function_syncro.SetManager(item.GetSyncroManager());
 }