コード例 #1
0
        public static string ToLogString(PSCommand psCommand, IEnumerable pipelineInput)
        {
            int           capacity      = 128;
            StringBuilder stringBuilder = new StringBuilder(capacity);

            if (pipelineInput != null)
            {
                stringBuilder.Append("Pipeline.");
                stringBuilder.Append(pipelineInput.OfType <object>().Count <object>());
                stringBuilder.Append("|");
            }
            for (int i = 0; i < psCommand.Commands.Count; i++)
            {
                Command command = psCommand.Commands[i];
                stringBuilder.Append(command.CommandText);
                foreach (CommandParameter commandParameter in command.Parameters)
                {
                    stringBuilder.Append(".");
                    stringBuilder.Append(commandParameter.Name);
                    stringBuilder.Append("=");
                    stringBuilder.Append(EcpTraceExtensions.FormatParameterValue(commandParameter.Value));
                }
                if (i != psCommand.Commands.Count - 1)
                {
                    stringBuilder.Append("|");
                }
            }
            return(stringBuilder.ToString());
        }
コード例 #2
0
        public static string ToTraceString(this PSCommand command)
        {
            StringBuilder stringBuilder = new StringBuilder();

            foreach (Command command2 in command.Commands)
            {
                stringBuilder.Append(command2.CommandText);
                stringBuilder.Append(" ");
                foreach (CommandParameter commandParameter in command2.Parameters)
                {
                    string format = (commandParameter.Value != null && commandParameter.Value.GetType() == typeof(bool)) ? "-{0}:{1} " : "-{0} {1} ";
                    stringBuilder.AppendFormat(format, commandParameter.Name, EcpTraceExtensions.FormatParameterValue(commandParameter.Value));
                }
                stringBuilder.Append("\n");
            }
            return(stringBuilder.ToString());
        }