private static void AppendFormatCommandParameterInfo(CommandParameterInfo parameter, Text.StringBuilder result) { if (result.Length > 0) { // Add a space between parameters result.Append(" "); } if (parameter.ParameterType == typeof(SwitchParameter)) { result.AppendFormat(CultureInfo.InvariantCulture, parameter.IsMandatory ? "-{0}" : "[-{0}]", parameter.Name); } else { string parameterTypeString = GetParameterTypeString(parameter.ParameterType, parameter.Attributes); if (parameter.IsMandatory) { result.AppendFormat(CultureInfo.InvariantCulture, parameter.Position != int.MinValue ? "[-{0}] <{1}>" : "-{0} <{1}>", parameter.Name, parameterTypeString); } else { result.AppendFormat(CultureInfo.InvariantCulture, parameter.Position != int.MinValue ? "[[-{0}] <{1}>]" : "[-{0} <{1}>]", parameter.Name, parameterTypeString); } } }
/// <summary> /// <para> /// Returns a string of the ScalingPolicyDescription. /// </para> /// </summary> /// <returns> /// <para>A string representing the AddRemoveIncrementalNamedPartitionScalingMechanism object.</para> /// </returns> public override string ToString() { Text.StringBuilder sb = new Text.StringBuilder(); sb.AppendFormat("Trigger:{0} Mechanism:{1}", ScalingTrigger, ScalingMechanism); return(sb.ToString()); }
/// <summary> /// <para> /// Returns a string representation of the PartitionInstanceCountScaleMechanism. /// </para> /// </summary> /// <returns> /// <para>A string representing the PartitionInstanceCountScaleMechanism object.</para> /// </returns> public override string ToString() { Text.StringBuilder sb = new Text.StringBuilder(); sb.AppendFormat("Kind:{0} MinInstanceCount:{1},MaxInstanceCount:{2},ScaleIncrement:{3}", Kind, MinInstanceCount, MaxInstanceCount, ScaleIncrement); return(sb.ToString()); }
/// <summary> /// <para> /// Returns a string representation of the AverageLoadScalingPolicyDescription. /// </para> /// </summary> /// <returns> /// <para>A string representing the AverageLoadScalingPolicyDescription object.</para> /// </returns> public override string ToString() { Text.StringBuilder sb = new Text.StringBuilder(); sb.AppendFormat("Kind:{0},MetricName:{1},LowerLoadThreshold:{2},UpperLoadThreshold:{3},ScaleInterval:{4}", Kind, MetricName, LowerLoadThreshold, UpperLoadThreshold, ScaleInterval); return(sb.ToString()); }
/// <summary> /// Renders HTML for a drop down list with a preselected value /// </summary> /// <param name="helper"></param> /// <param name="list"></param> /// <param name="name"></param> /// <param name="text"></param> /// <returns></returns> public static MvcHtmlString DropDownListPreselectByText(this HtmlHelper helper, IEnumerable <SelectListItem> list, string name, string text) { System.Text.StringBuilder sb = new Text.StringBuilder(); sb.AppendFormat("<select id=\"{0}\" name=\"{0}\">", name, name); foreach (SelectListItem item in list) { if (text != null && item.Text.Equals(text)) { sb.AppendFormat(" <option value=\"{0}\" selected=\"selected\">{1}</option>", item.Value, item.Text); } else { sb.AppendFormat(" <option value=\"{0}\">{1}</option>", item.Value, item.Text); } } sb.Append("</select>"); return(new MvcHtmlString(sb.ToString())); }
public static MvcHtmlString ToolButton(this HtmlHelper helper, string id, string icon, string text, List <permModel> perm, string keycode, bool hr) { if (perm.Where(a => a.KeyCode == keycode).Count() > 0) { var sb = new Text.StringBuilder(); sb.AppendFormat("<a id=\"{0}\" style=\"float: left;\" class=\"l-btn l-btn-plain\">", id); sb.AppendFormat("<span class=\"l-btn-left\"><span class=\"l-btn-text {0}\" style=\"padding-left: 20px;\">", icon); sb.AppendFormat("{0}</span></span></a>", text); if (hr) { sb.Append("<div class=\"datagrid-btn-separator\"></div>"); } return(new MvcHtmlString(sb.ToString())); } else { return(new MvcHtmlString("")); } }
/// <summary> /// 返回异常所有信息 /// </summary> /// <param name="webHuanHang">是否为web换行</param> /// <param name="style">样式: color:red; </param> /// <returns></returns> public string GetAllExceptionMessage(bool webHuanHang = false, string style = "") { System.Text.StringBuilder message = new Text.StringBuilder(""); if (_HasException) { int index = 0; _ExceptionCollection.Reverse().Distinct().ToList().ForEach(x => { if (webHuanHang) { message.AppendFormat(@"<p style='{2}'>【{0}】:{1}</p>", index, x.Message, style); } else { message.AppendLine(x.Message); } index++; }); } return(message.ToString()); }
/// <summary> /// Returns error context in the format [[errorContextInfo, ]line ddd, column ddd]. /// Returns empty string if errorPosition is less than 0 and errorContextInfo is not specified. /// </summary> internal static string FormatErrorContext( string commandText, int errorPosition, string errorContextInfo, bool loadErrorContextInfoFromResource, out int lineNumber, out int columnNumber) { Debug.Assert(errorPosition > -1, "position in input stream cannot be < 0"); Debug.Assert(errorPosition <= commandText.Length, "position in input stream cannot be greater than query text size"); if (loadErrorContextInfoFromResource) { errorContextInfo = !String.IsNullOrEmpty(errorContextInfo) ? EntityRes.GetString(errorContextInfo) : String.Empty; } // // Replace control chars and newLines for single representation characters // StringBuilder sb = new StringBuilder(commandText.Length); for (int i = 0; i < commandText.Length; i++) { Char c = commandText[i]; if (CqlLexer.IsNewLine(c)) { c = '\n'; } else if ((Char.IsControl(c) || Char.IsWhiteSpace(c)) && ('\r' != c)) { c = ' '; } sb.Append(c); } commandText = sb.ToString().TrimEnd(new char[] { '\n' }); // // Compute line and column // string[] queryLines = commandText.Split(new char[] { '\n' }, StringSplitOptions.None); for (lineNumber = 0, columnNumber = errorPosition; lineNumber < queryLines.Length && columnNumber > queryLines[lineNumber].Length; columnNumber -= (queryLines[lineNumber].Length + 1), ++lineNumber) { ; } ++lineNumber; // switch lineNum and colNum to 1-based indexes ++columnNumber; // // Error context format: "[errorContextInfo,] line ddd, column ddd" // sb = new Text.StringBuilder(); if (!String.IsNullOrEmpty(errorContextInfo)) { sb.AppendFormat(CultureInfo.CurrentCulture, "{0}, ", errorContextInfo); } if (errorPosition >= 0) { sb.AppendFormat(CultureInfo.CurrentCulture, "{0} {1}, {2} {3}", System.Data.Entity.Strings.LocalizedLine, lineNumber, System.Data.Entity.Strings.LocalizedColumn, columnNumber); } return(sb.ToString()); }