Exemple #1
0
        public virtual string Run(IRunOptions runOptions)
        {
            var process = new Process
                        {
                            StartInfo =
                                {
                                    FileName = runOptions.Command,
                                    Arguments = runOptions.Arguments,
                                    UseShellExecute = false,
                                    RedirectStandardOutput = true
                                }
                        };
            process.Start();
            var output = process.StandardOutput.ReadToEnd();
            process.WaitForExit();

            return output;
        }
Exemple #2
0
        public void RunOptionsUpdateCallback(string key, CacheItemUpdateReason reason, out object expensiveObject, out CacheDependency dependency, out DateTime absoluteExpiration, out TimeSpan slidingExpiration)
        {
            // 注意哦:在这个方法中,不要出现【未处理异常】,否则缓存对象将被移除。

            // 说明:这里并不关心参数reason,因为我根本就没有使用过期时间  所以,只有一种原因:依赖的文件发生了改变。

            expensiveObject = CacheDependencyValueObj;
            dependency = new CacheDependency(Path.Combine(Global.App_DataDir, fileName));
            absoluteExpiration = Cache.NoAbsoluteExpiration;
            slidingExpiration = Cache.NoSlidingExpiration;

            // 由于事件发生时,文件可能还没有完全关闭,所以只好让程序稍等。
            System.Threading.Thread.Sleep(50);

            // 重新加载配置参数
            _options = LoadRunOptions();
        }
 public ValidationRunOptions(IIdentifiable options)
     : base(options)
 {
     _options = options as IRunOptions;
 }
Exemple #4
0
 public string Run(IRunOptions runOptions)
 {
     return new ProcessRunner().Run(runOptions);
 }