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


C# IExecutionContext类代码示例

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


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


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