예제 #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
 internal static string FormatParameterValue(object value)
 {
     if (value is IDictionary)
     {
         return((value as IDictionary).ToTraceString());
     }
     if (value is IEnumerable && !(value is string))
     {
         return((value as IEnumerable).ToTraceString());
     }
     return(EcpTraceExtensions.FormatNonListParameterValue(value));
 }
예제 #3
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());
        }
예제 #4
0
        public static string ToTraceString(this IDictionary collection)
        {
            if (collection == null)
            {
                return("$null");
            }
            StringBuilder stringBuilder = new StringBuilder("@{");

            foreach (object obj in collection)
            {
                DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
                stringBuilder.Append(string.Format("{0}={1},", EcpTraceExtensions.FormatNonListParameterValue(dictionaryEntry.Key), EcpTraceExtensions.FormatNonListParameterValue(dictionaryEntry.Value)));
            }
            if (stringBuilder[stringBuilder.Length - 1] == ',')
            {
                stringBuilder.Remove(stringBuilder.Length - 1, 1);
            }
            stringBuilder.Append("}");
            return(stringBuilder.ToString());
        }
예제 #5
0
        public static string ToTraceString(this IEnumerable pipeline)
        {
            if (pipeline == null)
            {
                return("$null");
            }
            if (pipeline is string)
            {
                return(pipeline as string);
            }
            StringBuilder stringBuilder = new StringBuilder("@(");

            foreach (object value in pipeline)
            {
                stringBuilder.Append(EcpTraceExtensions.FormatNonListParameterValue(value) + ",");
            }
            if (stringBuilder[stringBuilder.Length - 1] == ',')
            {
                stringBuilder.Remove(stringBuilder.Length - 1, 1);
            }
            stringBuilder.Append(")");
            return(stringBuilder.ToString());
        }