コード例 #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());
 }