• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IExecutionContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IExecutionContext的典型用法代码示例。如果您正苦于以下问题:C# IExecutionContext类的具体用法?C# IExecutionContext怎么用?C# IExecutionContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IExecutionContext类属于命名空间,在下文中一共展示了IExecutionContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Execute

        public override CommandResultCode Execute(IExecutionContext context, CommandArguments args)
        {
            ISettingsHandler handler = Application as ISettingsHandler;
            if (handler == null) {
                Error.WriteLine("The application doesn't support settings.");
                return CommandResultCode.ExecutionFailed;
            }

            if (args.MoveNext())
                return CommandResultCode.SyntaxError;

            VarColumns[0].ResetWidth();
            VarColumns[1].ResetWidth();

            TableRenderer table = new TableRenderer(VarColumns, Out);
            table.EnableHeader = true;
            table.EnableFooter = true;
            foreach(KeyValuePair<string, string> setting in handler.Settings) {
                if (setting.Key == ApplicationSettings.SpecialLastCommand)
                    continue;

                ColumnValue[] row = new ColumnValue[4];
                row[0] = new ColumnValue(setting.Key);
                row[1] = new ColumnValue(setting.Value);
                table.AddRow(row);
            }

            table.CloseTable();
            Error.WriteLine();

            return CommandResultCode.Success;
        }
开发者ID:deveel,项目名称:dshell,代码行数:32,代码来源:VariablesCommand.cs


示例2: AssignValue

        public void AssignValue(IExecutionContext context, object val)
        {
            object obj = Expr1.Eval(context);

            if(obj is Hashtable)
            {
                ((Hashtable)obj)[Expr2.Eval(context)] = val;
                return;
            }
            else if(obj is Array)
            {
                object index = Expr2.Eval(context);
                if(!IsInteger(index))
                    throw new Exception("Index pole musí být celočíselný");
                ((Array)obj).SetValue(val, Convert.ToInt64(index));
                return;
            }
            else
            {
                object index = Expr2.Eval(context);
                Type t = obj.GetType();
                // find indexer //
                PropertyInfo prop = t.GetProperty("Item");
                prop.GetSetMethod().Invoke(obj, new object[] {index, val});
            }
            //throw new System.NotImplementedException ();
        }
开发者ID:langpavel,项目名称:LPS-old,代码行数:27,代码来源:ArrayMember.cs


示例3: GetBuildDirectoryHashKey

        public string GetBuildDirectoryHashKey(IExecutionContext executionContext, ServiceEndpoint endpoint)
        {
            // Validate parameters.
            Trace.Entering();
            ArgUtil.NotNull(executionContext, nameof(executionContext));
            ArgUtil.NotNull(executionContext.Variables, nameof(executionContext.Variables));
            ArgUtil.NotNull(endpoint, nameof(endpoint));
            ArgUtil.NotNull(endpoint.Url, nameof(endpoint.Url));

            // Calculate the hash key.
            const string Format = "{{{{ \r\n    \"system\" : \"build\", \r\n    \"collectionId\" = \"{0}\", \r\n    \"definitionId\" = \"{1}\", \r\n    \"repositoryUrl\" = \"{2}\", \r\n    \"sourceFolder\" = \"{{0}}\",\r\n    \"hashKey\" = \"{{1}}\"\r\n}}}}";
            string hashInput = string.Format(
                CultureInfo.InvariantCulture,
                Format,
                executionContext.Variables.System_CollectionId,
                executionContext.Variables.System_DefinitionId,
                endpoint.Url.AbsoluteUri);
            using (SHA1 sha1Hash = SHA1.Create())
            {
                byte[] data = sha1Hash.ComputeHash(Encoding.UTF8.GetBytes(hashInput));
                StringBuilder hexString = new StringBuilder();
                for (int i = 0; i < data.Length; i++)
                {
                    hexString.Append(data[i].ToString("x2"));
                }

                return hexString.ToString();
            }
        }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:29,代码来源:SourceProvider.cs


示例4: Execute

        public IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
        {
            List<IDocument> results = new List<IDocument>();
            IEnumerable<IDocument> documents = inputs;
            foreach (Tuple<DocumentConfig, IModule[]> condition in _conditions)
            {
                // Split the documents into ones that satisfy the predicate and ones that don't
                List<IDocument> handled = new List<IDocument>();
                List<IDocument> unhandled = new List<IDocument>();
                foreach (IDocument document in documents)
                {
                    if (condition.Item1 == null || condition.Item1.Invoke<bool>(document, context))
                    {
                        handled.Add(document);
                    }
                    else
                    {
                        unhandled.Add(document);
                    }
                }

                // Run the modules on the documents that satisfy the predicate
                results.AddRange(context.Execute(condition.Item2, handled));

                // Continue with the documents that don't satisfy the predicate
                documents = unhandled;
            }

            // Add back any documents that never matched a predicate
            results.AddRange(documents);

            return results;
        }
开发者ID:ibebbs,项目名称:Wyam,代码行数:33,代码来源:If.cs


示例5: Execute

 public IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
 {
     return inputs
        .AsParallel()
        .Select(input =>
        {
            try
            {
                object data = _data(input, context);
                if (data != null)
                {
                    string result = JsonConvert.SerializeObject(data,
                        _indenting ? Formatting.Indented : Formatting.None);
                    if (string.IsNullOrEmpty(_destinationKey))
                    {
                        return context.GetDocument(input, result);
                    }
                    return context.GetDocument(input, new MetadataItems
                    {
                        {_destinationKey, result}
                    });
                }
            }
            catch (Exception ex)
            {
                Trace.Error("Error serializing JSON for {0}: {1}", input.Source, ex.ToString());
            }
            return input;
        })
        .Where(x => x != null);
 }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:31,代码来源:GenerateJson.cs


示例6: Run

 public override void Run(IExecutionContext context)
 {
     if(IsInitializer)
     {
         context.InitVariable(Name);
     }
 }
开发者ID:langpavel,项目名称:LPS-old,代码行数:7,代码来源:Variable.cs


示例7: Do

        public override CommandResult Do(IExecutionContext context)
        {
            RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"CLSID\" + ClassId);
            context.SaveResult(ResultName, key != null);

            return CommandResult.Next;
        }
开发者ID:vgrinin,项目名称:gin,代码行数:7,代码来源:IsCOMInstalled.cs


示例8: Execute

        public override CommandResultCode Execute(IExecutionContext context, CommandArguments args)
        {
            if (args.MoveNext())
                return CommandResultCode.SyntaxError;

            NetworkContext networkContext = context as NetworkContext;
            if (networkContext == null)
                return CommandResultCode.ExecutionFailed;

            Out.WriteLine();
            Out.WriteLine("refreshing...");
            Out.Flush();

            networkContext.Network.Refresh();

            try {
                //TODO:
                // networkContext.Network.Configuration.Reload();
            } catch (IOException e) {
                Error.WriteLine("Unable to refresh network config due to IO error");
                Error.WriteLine(e.Message);
                Error.WriteLine(e.StackTrace);
            }

            Out.WriteLine("done.");
            Out.WriteLine();

            return CommandResultCode.Success;
        }
开发者ID:erpframework,项目名称:cloudb,代码行数:29,代码来源:RefreshCommand.cs


示例9: HandleException

        protected override void HandleException(IExecutionContext executionContext, Exception exception)
        {

            var putObjectRequest = executionContext.RequestContext.OriginalRequest as PutObjectRequest;
            if (putObjectRequest != null)
            {
                // If InputStream was a HashStream, compare calculated hash to returned etag
                HashStream hashStream = putObjectRequest.InputStream as HashStream;
                if (hashStream != null)
                {
                    // Set InputStream to its original value
                    putObjectRequest.InputStream = hashStream.GetNonWrapperBaseStream();
                }
            }

            var uploadPartRequest = executionContext.RequestContext.OriginalRequest as UploadPartRequest;
            if (uploadPartRequest != null)
            {
                // If InputStream was a HashStream, compare calculated hash to returned etag
                HashStream hashStream = uploadPartRequest.InputStream as HashStream;
                if (hashStream != null)
                {
                    // Set InputStream to its original value
                    uploadPartRequest.InputStream = hashStream.GetNonWrapperBaseStream();
                }
            }

            if (executionContext.RequestContext.Request != null)
                AmazonS3Client.CleanupRequest(executionContext.RequestContext.Request);
        }
开发者ID:yridesconix,项目名称:aws-sdk-net,代码行数:30,代码来源:AmazonS3ExceptionHandler.cs


示例10: Execute

 public IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
 {
     return _searchPattern != null
         ? Execute(null, _searchPattern, context)
         : inputs.AsParallel().SelectMany(input =>
             Execute(input, _sourcePathDelegate.Invoke<string>(input, context), context));
 }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:7,代码来源:CopyFiles.cs


示例11:

 IEnumerable<IDocument> IModule.Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
 {
     if (_executeDocuments != null)
         return inputs.SelectMany(x => _executeDocuments.Invoke<IEnumerable<IDocument>>(x, context) ?? Array.Empty<IDocument>());
     else
         return _executeContext.Invoke<IEnumerable<IDocument>>(context) ?? Array.Empty<IDocument>();
 }
开发者ID:martinvobr,项目名称:Wyam,代码行数:7,代码来源:Execute.cs


示例12: DoProcessRequest

        public override void DoProcessRequest(IExecutionContext context)
        {
            userProfile profile = UserHelper.Instance.LoadUser(username);
            if (profile == null || !profile.Authenticate(password))
            {
                ReportError(null, "The user name or password is incorrect");
                return;
            }

            else
                // this is the key line. this sets the profile as the 
                // current user, and marks the session as authenticated
                context.Authenticate(profile);

            if (ContentTypeHelper.Instance.Parse(defaultContentType) != profile.UserType.ContentType)
                defaultContentType = ContentTypeHelper.Instance.GetSimpleName(profile.UserType.ContentType);

            // hack. we didn't create a table to store the roles, so now 
            // we're faking them through here
            if (profile.UserType.Equals(UserType.Company)) {
                var node = profile.role.AppendNode();
                node.Name = "company";
            }

            if (String.IsNullOrEmpty(originalRequest))
                context.Transfer("/default");
            else
                context.Transfer(HttpUtility.UrlDecode(originalRequest));
        }
开发者ID:jijo-paulose,项目名称:bistro-framework,代码行数:29,代码来源:Signin.cs


示例13: WriteLog

        /// <summary>
        /// Writes the log.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="stream">The stream.</param>
        /// <param name="callback">The callback for UI updates.</param>
        public void WriteLog(IExecutionContext context, Stream stream, ProgressCallback callback)
        {
            using (BinaryWriter s = new BinaryWriter(stream, Encoding.ASCII))
            {
                s.Write("[PacketLogConverter v1]");

                foreach (PacketLog log in context.LogManager.Logs)
                {
                    for (int i = 0; i < log.Count; i++)
                    {
                        if (callback != null && (i & 0xFFF) == 0) // update progress every 4096th packet
                            callback(i + 1, log.Count);

                        Packet packet = log[i];
                        if (context.FilterManager.IsPacketIgnored(packet))
                            continue;

                        byte[] buf = packet.GetBuffer();
                        s.Write((ushort) buf.Length);
                        s.Write(packet.GetType().FullName);
                        s.Write((ushort) packet.Code);
                        s.Write((byte) packet.Direction);
                        s.Write((byte) packet.Protocol);
                        s.Write(packet.Time.Ticks);
                        s.Write(buf);
                    }
                }
            }
        }
开发者ID:Dawn-of-Light,项目名称:PacketLogConverter,代码行数:35,代码来源:PacketLogConverterV1LogWriter.cs


示例14: WriteLog

        /// <summary>
        /// Writes the log.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="stream">The stream.</param>
        /// <param name="callback">The callback for UI updates.</param>
        public void WriteLog(IExecutionContext context, Stream stream, ProgressCallback callback)
        {
            TimeSpan baseTime = new TimeSpan(0);
            using (StreamWriter s = new StreamWriter(stream))
            {
                foreach (PacketLog log in context.LogManager.Logs)
                {
                    // Log file name
                    s.WriteLine();
                    s.WriteLine();
                    s.WriteLine("Log file: " + log.StreamName);
                    s.WriteLine("==============================================");

                    for (int i = 0; i < log.Count; i++)
                    {
                        // Update progress every 4096th packet
                        if (callback != null && (i & 0xFFF) == 0)
                            callback(i, log.Count - 1);

                        Packet packet = log[i];
                        if (context.FilterManager.IsPacketIgnored(packet))
                            continue;

                        s.WriteLine(packet.ToHumanReadableString(baseTime, true));
                    }
                }
            }
        }
开发者ID:Dawn-of-Light,项目名称:PacketLogConverter,代码行数:34,代码来源:ShortLogWriter.cs


示例15: Execute

        public override CommandResultCode Execute(IExecutionContext context, CommandArguments args)
        {
            if (args.Count != 1)
                return CommandResultCode.SyntaxError;

            PropertyRegistry properties = Properties;
            if (properties == null) {
                Application.Error.WriteLine("the current context does not support properties.");
                return CommandResultCode.ExecutionFailed;
            }

            if (!args.MoveNext())
                return CommandResultCode.SyntaxError;

            String name = args.Current;
            PropertyHolder holder = properties.GetProperty(name);
            if (holder == null)
                return CommandResultCode.ExecutionFailed;

            string defaultValue = holder.DefaultValue;

            try {
                properties.SetProperty(name, defaultValue);
            } catch (Exception) {
                Application.Error.WriteLine("setting to default '" + defaultValue + "' failed.");
                return CommandResultCode.ExecutionFailed;
            }
            return CommandResultCode.Success;
        }
开发者ID:deveel,项目名称:dshell,代码行数:29,代码来源:ResetPropertyCommand.cs


示例16: EvaluateCoreAsync

        protected override async Task<object> EvaluateCoreAsync(IExecutionContext executionContext, CancellationToken cancellationToken)
        {
            var date = (DateTime) await DateParameter.EvaluateAsync(executionContext, cancellationToken);
            var amount = (double) await AmountParameter.EvaluateAsync(executionContext, cancellationToken);

            return date + _service.GetTimeSpan(amount);           
        }
开发者ID:CaptiveAire,项目名称:VPL,代码行数:7,代码来源:AddToDate.cs


示例17: AssignValue

 public void AssignValue(IExecutionContext context, object val)
 {
     if(IsInitializer)
         context.InitVariable(Name, val);
     else
         context.SetVariable(Name, val);
 }
开发者ID:langpavel,项目名称:LPS-old,代码行数:7,代码来源:Variable.cs


示例18: Eval

        public override object Eval(IExecutionContext context)
        {
            object vl = ExprLow.Eval(context);
            object vh = ExprHigh.Eval(context);
            if(vl != null && vh != null)
            {
                if(IsNumeric(vl) && IsNumeric(vh))
                    return new Range<Decimal>(Convert.ToDecimal(vl), Convert.ToDecimal(vh), this.RangeType);
                if(vl is DateTime && vh is DateTime)
                    return new Range<DateTime>((DateTime)vl, (DateTime)vh, this.RangeType);
            }
            else if(vl != null)
            {
                if(IsNumeric(vl))
                    return new Range<Decimal>(Convert.ToDecimal(vl), null, this.RangeType);
                if(vl is DateTime)
                    return new Range<DateTime>((DateTime)vl, null, this.RangeType);
            }
            else if(vh != null)
            {
                if(IsNumeric(vh))
                    return new Range<Decimal>(null, Convert.ToDecimal(vh), this.RangeType);
                if(vl is DateTime && vh is DateTime)
                    return new Range<DateTime>(null, (DateTime)vh, this.RangeType);
            }

            throw new InvalidOperationException();
        }
开发者ID:langpavel,项目名称:LPS-old,代码行数:28,代码来源:RangeExpression.cs


示例19: Execute

        public IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
        {
            if (_modules != null)
            {
                Dictionary<string, object> metadata = new Dictionary<string, object>();

                // Execute the modules for each input document
                if (_forEachDocument)
                {
                    return inputs.Select(input =>
                    {
                        foreach (IDocument result in context.Execute(_modules, new[] { input }))
                        {
                            foreach (KeyValuePair<string, object> kvp in result)
                            {
                                metadata[kvp.Key] = kvp.Value;
                            }
                        }
                        return input.Clone(metadata);
                    });
                }

                // Execute the modules once and apply to each input document
                foreach (IDocument result in context.Execute(_modules))
                {
                    foreach (KeyValuePair<string, object> kvp in result)
                    {
                        metadata[kvp.Key] = kvp.Value;
                    }
                }
                return inputs.Select(input => input.Clone(metadata));
            }

            return inputs.Select(x => x.Clone(new [] { new KeyValuePair<string, object>(_key, _metadata.GetValue(x, context)) }));
        }
开发者ID:st1pps,项目名称:Wyam,代码行数:35,代码来源:Meta.cs


示例20: ExecutionContext

 protected ExecutionContext(IExecutionContext ParentContext, IExecutionContext GlobalContext, ToolScriptParser Parser)
 {
     this.GlobalContext = GlobalContext ?? this;
     this.ParentContext = ParentContext;
     this.Parser = Parser;
     LocalVariables = new Dictionary<string, object>();
 }
开发者ID:langpavel,项目名称:LPS-old,代码行数:7,代码来源:ExecutionContext.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IExecutionHandler类代码示例发布时间:2022-05-24
下一篇:
C# IExceptionHandler类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap