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


C# ITask.GetType方法代码示例

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


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

示例1: Execute

        public IResponse Execute(ITask task)
        {
            Debug.WriteLine(string.Format("{0}: Received task", DateTime.Now));

            bool successful = true;
            Exception exception = null;
            IResult result = null;
            try
            {
                ITaskExecutor taskExecutor = taskExecuterFactory.CreateExecuterFor(task);
                Debug.WriteLine(string.Format("{0}: Executing {1}", DateTime.Now, task.GetType().Name));
                result = taskExecutor.Execute(task);
            }
            catch(Exception e)
            {
                Debug.WriteLine(string.Format("{0}: Error in {1}, {2} ({3})", DateTime.Now, task.GetType().Name, e.GetType().Name, e.Message));
                successful = false;
                exception = e;
                logger.LogException(LogLevel.Debug, "Exception when executing task: " + task.GetType().Name, e);
            }

            var resultType = task.GetType().GetInterfaces().Single(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof (ITask<>)).GetGenericArguments()[0];

            return CreateResponse(resultType, result, successful, exception);
        }
开发者ID:larsudengaard,项目名称:deploy-commander,代码行数:25,代码来源:SoldierService.cs

示例2: Release

        public virtual void Release(ITask task)
        {
            try
            {
                var disposable = task as IDisposable;

                if (disposable == null)
                {
                    return;
                }

                disposable.Dispose();

                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug("Task {0} successfully disposed.", task);
                }
            }
            catch (Exception ex)
            {
                if (!Logger.IsErrorEnabled) return;

                var errorMessage = string.Format("Task {0} of type {1} throws exception on dispose.", task, task.GetType());
                Logger.ErrorException(errorMessage, ex);
            }
        }
开发者ID:Codestellation,项目名称:DarkFlow,代码行数:26,代码来源:DefaultReleaser.cs

示例3: GetDescriptionFor

        public static string GetDescriptionFor(ITask task)
        {
            var taskDescriptionAttribute = task.GetType().GetAttribute<TaskDescriptionAttribute>();

            return taskDescriptionAttribute != null
                    ? taskDescriptionAttribute.Description
                    : NoTaskDescriptionGivenMessage;
        }
开发者ID:DarrellMozingo,项目名称:Taskie,代码行数:8,代码来源:TaskMetaHelper.cs

示例4: CreateExecuterFor

        public ITaskExecutor CreateExecuterFor(ITask task)
        {
            Type taskType = task.GetType();
            Type resultType = taskType.GetInterfaces().Single(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof (ITask<>)).GetGenericArguments()[0];
            Type genericCommandHandler = typeof (ITaskExecutor<,>).MakeGenericType(taskType, resultType);
            var type = typeof(StopWebsiteExecutor).Assembly.GetTypes().Single(genericCommandHandler.IsAssignableFrom);

            return (ITaskExecutor)Activator.CreateInstance(type);
        }
开发者ID:larsudengaard,项目名称:deploy-commander,代码行数:9,代码来源:TaskExecuterFactory.cs

示例5: GetDependenciesFor

        public IEnumerable<ITask> GetDependenciesFor(ITask task)
        {
            TypeDependencyGetter getter;

            var type = task.GetType();

            if (!DependencyGetters.TryGetValue(type, out getter)) {
                getter = new TypeDependencyGetter(type);
            }

            return getter.GetDependencies(task);
        }
开发者ID:jimbutler,项目名称:bounce,代码行数:12,代码来源:TaskDependencyFinder.cs

示例6: Execute

        public void Execute(ITask task, bool throwOnError = false)
        {
            JobsEventSource.Log.TaskExecuting(task.GetType().Name);

            var startTime = DateTime.UtcNow;

            try
            {
                task.Execute();

                JobsEventSource.Log.TaskExecuted(task.GetType().Name, (DateTime.UtcNow - startTime).ToString());
            }
            catch (Exception ex)
            {
                JobsEventSource.Log.TaskExecutionError(task.GetType().Name, ex.GetType().Name, ex.Message, ex.StackTrace);

                // Make sure the exception bubbles up and stops the execution of other tasks.
                if (throwOnError)
                    throw;
            }
        }
开发者ID:Mecabot,项目名称:RedDog,代码行数:21,代码来源:Job.cs

示例7: FinishTask

        private void FinishTask(ITask task)
        {
            var TaskType = task.GetType();
            var NextTime = task.NextExecutionTime();
            _TaskFactory.DestroyTask(task);

            var Timer = new Timer();
            Timer.Elapsed += (o, e) =>
                {
                    Timer.Dispose();
                    CreateTask(TaskType);
                };
            Timer.Interval = NextTime.TotalMilliseconds;
            Timer.Start();
        }
开发者ID:brsmith,项目名称:BibleOnTwitter,代码行数:15,代码来源:TaskService.cs

示例8: TryMatch

        public MatchResult TryMatch(ITask task)
        {
            Contract.Require(task != null, "task != null");

            var type = task.GetType();
            MatchResult result;
            if (_cache.TryGetValue(type, out result))
            {
                return result;
            }

            result = ProbeNamespace(type);

            CollectionUtils.ThreadSafeAdd(ref _cache, type, result);

            return result;
        }
开发者ID:Codestellation,项目名称:DarkFlow,代码行数:17,代码来源:NamespaceMatcher.cs

示例9: Match

        protected override bool Match(ITask task)
        {
            Contract.Require(task != null, "task != null");

            var type = task.GetType();

            bool result;

            if (_cache.TryGetValue(type, out result))
            {
                return result;
            }

            result = PerformAttributesMatch(type);

            CollectionUtils.ThreadSafeAdd(ref _cache, type, result);

            return result;
        }
开发者ID:Codestellation,项目名称:DarkFlow,代码行数:19,代码来源:AttributeMatcher.cs

示例10: RegisteredTask

 public RegisteredTask(ITask task)
 {
     Argument.IsNotNull(task, nameof(task));
     TaskInstance = task;
     Name = task.GetType().Name;
 }
开发者ID:vetterd,项目名称:CSBuild,代码行数:6,代码来源:RegisteredTask.cs

示例11: CBTTaskLogHelper

 public CBTTaskLogHelper(ITask task)
     : this(task, task.GetType().Name)
 {
 }
开发者ID:CommonBuildToolset,项目名称:CBT.Core,代码行数:4,代码来源:CBTTaskLogHelper.cs

示例12: GetInterceptorForTask

 private static IInterceptor GetInterceptorForTask(ITask t)
 {
     if (cfgSec == null)
         return null;
     TaskElement te = cfgSec.FindTaskElementByType(t.GetType());
     if (te == null || !te.UserInterceptor)
         return null;
     IInterceptor retVal = te.InterceptorElement.Interceptor;
     if (retVal == null)
         retVal = cfgSec.DefaultInterceptor;
     return retVal;
 }
开发者ID:kailuowang,项目名称:MindLib,代码行数:12,代码来源:TaskManager.cs

示例13: BuildTaskLoggers

 public BuildTaskLoggers(MSBuildFramework.IBuildEngine buildEngine, ITask task, IArgumentProvider arguments)
 {
     BuildLogger logger = new BuildLogger(buildEngine, task.GetType().ToString());
     this.RegisterLogger(LoggerType.Result, logger);
     this.RegisterLogger(LoggerType.Status, logger);
 }
开发者ID:ramarag,项目名称:XTask,代码行数:6,代码来源:BuildTaskInteraction.cs

示例14: GetMemberValue

        private string GetMemberValue(ITask task, string memberName)
        {
            var tuple = Tuple.Create(task.GetType(), memberName);
            Func<ITask, string> getter;

            if(_cachedGetters.TryGetValue(tuple, out getter))
            {
                return getter(task);
            }

            getter = _cachedGetters.GetOrAdd(tuple, BuildGetter);
            return getter(task);
        }
开发者ID:Codestellation,项目名称:DarkFlow,代码行数:13,代码来源:ContentMatcher.cs

示例15: GetTaskAPs

 public Decimal GetTaskAPs(ITask task)
 {
     if (task is Path) {
         return this.GetPathAPs((Path)task);
     } else {
         throw new UnsupportedTaskType("No method implemented to calculate action points for task type '"+task.GetType().ToString()+"'");
     }
 }
开发者ID:pdabbadabba,项目名称:Beatdown,代码行数:8,代码来源:Unit.cs


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