当前位置: 首页>>代码示例>>C#>>正文


C# Action.GetType方法代码示例

本文整理汇总了C#中System.Action.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Action.GetType方法的具体用法?C# Action.GetType怎么用?C# Action.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Action的用法示例。


在下文中一共展示了Action.GetType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

        public static Delegate Create(EventInfo eventInfo, Action action)
        {
            var handlerType = eventInfo.EventHandlerType;
            var eventParameters = handlerType.GetMethod("Invoke").GetParameters();

            var parameters = eventParameters.Select(p => Expression.Parameter(p.ParameterType, "x"));
            var body = Expression.Call(Expression.Constant(action), action.GetType().GetMethod("Invoke"));
            var lambda = Expression.Lambda(body, parameters.ToArray());
            return Delegate.CreateDelegate(handlerType, lambda.Compile(), "Invoke", false);
        }
开发者ID:Talisan,项目名称:Terrastructor,代码行数:10,代码来源:EventBuilder.cs

示例2: RunAction

        protected TimeSpan RunAction(Action action, int iterations, string actionName)
        {
            actionName = actionName ?? action.GetType().Name;
            var ticksTaken = Measure(action, iterations);
            var timeSpan = TimeSpan.FromSeconds(ticksTaken * 1d / Stopwatch.Frequency);

            Log("{0} took {1}ms ({2} ticks), avg: {3} ticks", actionName, timeSpan.TotalMilliseconds, timeSpan.Ticks, (timeSpan.Ticks / iterations));

            return timeSpan;
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:10,代码来源:PerfTestBase.cs

示例3: EventPropegator

        public EventPropegator(object instance, EventInfo evt, Action<object, EventArgs> handler)
        {
            _instance = instance;
            _evt = evt;
            _disposed = false;

            var methodInfo = handler.GetType().GetMethod("Invoke");
            _delegate = Delegate.CreateDelegate(evt.EventHandlerType, handler, methodInfo);

            evt.AddEventHandler(instance, _delegate);
        }
开发者ID:caesay,项目名称:NearSight,代码行数:11,代码来源:EventPropegator.cs

示例4: VariableSubscription

        public VariableSubscription(
            VariableSubscriptionToken token,
            Action<DebugEvaluationResult> executeAction,
            Action<VariableSubscription> unsubscribeAction) {

            Token = token;

            _weakReference = new WeakReference(executeAction.Target);
            _method = executeAction.Method;
            _delegateType = executeAction.GetType();

            _unsubscribe = unsubscribeAction;
        }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:13,代码来源:VariableSubscription.cs

示例5: AddEventHandler

        public static void AddEventHandler(EventInfo eventInfo, object item, Action<object, EventArgs> action)
        {
            var parameters = eventInfo.EventHandlerType
            .GetMethod("Invoke")
            .GetParameters()
            .Select(parameter => Expression.Parameter(parameter.ParameterType))
            .ToArray();

              var invoke = action.GetType().GetMethod("Invoke");

              var handler = Expression.Lambda(
              eventInfo.EventHandlerType,
              Expression.Call(Expression.Constant(action), invoke, parameters[0], parameters[1]),
              parameters
            )
            .Compile();

              eventInfo.AddEventHandler(item, handler);
        }
开发者ID:Serj-Tm,项目名称:SoftTech,代码行数:19,代码来源:EventTest.cs

示例6: Add

 public static void Add(DateTime executeTime, Action<string[]> action, string[] args)
 {
     DateTime now = DateTime.Now;
     if (executeTime < DateTime.Now)
     {
         executeTime = now.AddSeconds(1.0);
     }
     Maticsoft.TimerTask.Model.TaskTimer timer2 = new Maticsoft.TimerTask.Model.TaskTimer {
         IsSingle = true,
         ExecuteType = action.GetType().FullName,
         ExecuteTime = executeTime
     };
     TimeSpan span = (TimeSpan) (executeTime - now);
     timer2.Interval = (decimal) span.TotalMilliseconds;
     timer2.Params = args;
     Maticsoft.TimerTask.Model.TaskTimer model = timer2;
     model.ID = Maticsoft.TimerTask.BLL.TaskTimer.Add(model);
     Instance().CurrentTasks.Add(new Maticsoft.TimerTask.Timer(model, executeTime, action, new Action<Maticsoft.TimerTask.Model.TaskTimer>(Task.CallBack), args));
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:19,代码来源:Task.cs

示例7: createThread

        // Accepts a method that does not return a value
        // Creates a thread to run a function/method
        private void createThread(Action method)
        {
            // Create the thread object, passing in a method
            Thread aThread = new Thread(new ThreadStart(method));

            try
            {

                // Add a name for the thread
                aThread.Name = method.GetType().FullName.ToString();

                // Start the thread
                aThread.Start();

                // Wait for thread to start
                while (!aThread.IsAlive)
                {
                    // Do nothing, but wait
                }

                // Wait for thread to finish
                aThread.Join();

            }
            catch (System.Net.Mail.SmtpException ex)
            {
                // Wait for thread to finish
                aThread.Join();
                MessageBox.Show(ex.Message);

            }
            catch (Exception ex)
            {
                // Wait for thread to finish
                aThread.Join();
                throw ex;
            }
        }
开发者ID:kn1mwhi1,项目名称:EIAP,代码行数:40,代码来源:LogicTier.cs


注:本文中的System.Action.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。