本文整理汇总了C#中StringBuilder.AppendFormatLine方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuilder.AppendFormatLine方法的具体用法?C# StringBuilder.AppendFormatLine怎么用?C# StringBuilder.AppendFormatLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuilder
的用法示例。
在下文中一共展示了StringBuilder.AppendFormatLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Format
/// <summary>
/// Generates a detailed error message
/// </summary>
/// <param name="sassСompilationException">Sass compilation exception</param>
/// <returns>Detailed error message</returns>
public static string Format(SassСompilationException sassСompilationException)
{
string message = sassСompilationException.Text;
string filePath = sassСompilationException.File;
int lineNumber = sassСompilationException.LineNumber;
int columnNumber = sassСompilationException.ColumnNumber;
string sourceCode = sassСompilationException.Source;
string sourceFragment = SourceCodeNavigator.GetSourceFragment(sourceCode,
new SourceCodeNodeCoordinates(lineNumber, columnNumber));
var errorMessage = new StringBuilder();
errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_Message, message);
if (!string.IsNullOrWhiteSpace(filePath))
{
errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_File, filePath);
}
if (lineNumber > 0)
{
errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_LineNumber,
lineNumber.ToString(CultureInfo.InvariantCulture));
}
if (columnNumber > 0)
{
errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_ColumnNumber,
columnNumber.ToString(CultureInfo.InvariantCulture));
}
if (!string.IsNullOrWhiteSpace(sourceFragment))
{
errorMessage.AppendFormatLine("{1}:{0}{0}{2}", Environment.NewLine,
Strings.ErrorDetails_SourceFragment,
sourceFragment);
}
return errorMessage.ToString();
}
示例2: ToString
public override string ToString()
{
var builder = new StringBuilder();
builder.AppendFormatLine("First name: {0}", FirstName);
builder.AppendFormatLine("Last name: {0}", LastName);
builder.AppendFormatLine("Address: {0}", Address);
return builder.ToString();
}
示例3: WriteToString
public string WriteToString(ServerSettings serverSettings)
{
var sb = new StringBuilder();
sb.AppendFormatLine(@"server:{0}", serverSettings.ServerIp);
sb.AppendFormatLine(@"port:{0}", serverSettings.Port);
sb.AppendLine(";Timeout in seconds");
sb.AppendFormatLine(@"timeout:{0}", serverSettings.TimeoutInSeconds);
return sb.ToString();
}
示例4: Format
/// <summary>
/// Generates a detailed error message
/// </summary>
/// <param name="jsEngineLoadException">JavaScript engine load exception</param>
/// <returns>Detailed error message</returns>
public static string Format(JsEngineLoadException jsEngineLoadException)
{
var errorMessage = new StringBuilder();
errorMessage.AppendFormatLine("{0}: {1}", CommonStrings.ErrorDetails_Message,
jsEngineLoadException.Message);
if (!string.IsNullOrWhiteSpace(jsEngineLoadException.EngineMode))
{
errorMessage.AppendFormatLine("{0}: {1}", CommonStrings.ErrorDetails_EngineMode,
jsEngineLoadException.EngineMode);
}
return errorMessage.ToString();
}
示例5: CombineAssetContent
protected override string CombineAssetContent(IList<IAsset> assets)
{
var contentBuilder = new StringBuilder();
int assetCount = assets.Count;
int lastAssetIndex = assetCount - 1;
for (int assetIndex = 0; assetIndex < assetCount; assetIndex++)
{
IAsset asset = assets[assetIndex];
string assetContent = asset.Content.TrimEnd();
if (EnableTracing)
{
contentBuilder.AppendFormatLine("//#region URL: {0}", asset.Url);
}
contentBuilder.Append(assetContent);
if (!assetContent.EndsWith(";"))
{
contentBuilder.Append(";");
}
if (EnableTracing)
{
contentBuilder.AppendLine();
contentBuilder.AppendLine("//#endregion");
}
if (assetIndex != lastAssetIndex)
{
contentBuilder.AppendLine();
}
}
return contentBuilder.ToString();
}
示例6: ToString
public override void ToString(StringBuilder builder)
{
builder.AppendFormatLine("Seed: 0x{0:X8} Count: {1}", Seed, Count);
builder.Append("Client Seed: ");
ClientSeed.ToHexString(builder);
builder.AppendLine();
builder.Append("Server Seed: ");
ServerSeed.ToHexString(builder);
builder.AppendLine();
}
示例7: Error
/// <summary>
/// Logs a information about the error
/// </summary>
/// <param name="category">Error category</param>
/// <param name="message">Error message</param>
/// <param name="filePath">File path</param>
/// <param name="lineNumber">Line number on which the error occurred</param>
/// <param name="columnNumber">Column number on which the error occurred</param>
/// <param name="sourceFragment">Fragment of source code</param>
public override void Error(string category, string message, string filePath = "",
int lineNumber = 0, int columnNumber = 0, string sourceFragment = "")
{
var errorMessage = new StringBuilder();
errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_Category, category);
errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_Message, message);
if (!string.IsNullOrWhiteSpace(filePath))
{
errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_File, filePath);
}
if (lineNumber > 0)
{
errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_LineNumber, lineNumber);
}
if (columnNumber > 0)
{
errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_ColumnNumber, columnNumber);
}
if (!string.IsNullOrWhiteSpace(sourceFragment))
{
errorMessage.AppendFormatLine("{1}:{0}{0}{2}", Environment.NewLine,
Strings.ErrorDetails_SourceFragment, sourceFragment);
}
throw new MarkupMinificationException(errorMessage.ToString());
}
示例8: Output
private void Output(String msg, Boolean error = false)
{
var sb = new StringBuilder();
var start = txtOutput.TextLength;
sb.AppendFormatLine("> {0}", msg);
txtOutput.AppendText(sb.ToString());
txtOutput.Select(start, txtOutput.TextLength - 1);
txtOutput.SelectionColor = error ? Color.DarkRed : Color.Black;
txtOutput.DeselectAll();
txtOutput.Refresh();
}
示例9: Format
/// <summary>
/// Generates a detailed error message
/// </summary>
/// <param name="jsRuntimeException">JavaScript runtime exception</param>
/// <returns>Detailed error message</returns>
public static string Format(JsRuntimeException jsRuntimeException)
{
var errorMessage = new StringBuilder();
errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_Message,
jsRuntimeException.Message);
if (!string.IsNullOrWhiteSpace(jsRuntimeException.EngineName))
{
errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_EngineName,
jsRuntimeException.EngineName);
}
if (!string.IsNullOrWhiteSpace(jsRuntimeException.EngineVersion))
{
errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_EngineVersion,
jsRuntimeException.EngineVersion);
}
if (!string.IsNullOrWhiteSpace(jsRuntimeException.ErrorCode))
{
errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_ErrorCode,
jsRuntimeException.ErrorCode);
}
if (!string.IsNullOrWhiteSpace(jsRuntimeException.Category))
{
errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_Category,
jsRuntimeException.Category);
}
if (jsRuntimeException.LineNumber > 0)
{
errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_LineNumber,
jsRuntimeException.LineNumber.ToString(CultureInfo.InvariantCulture));
}
if (jsRuntimeException.ColumnNumber > 0)
{
errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_ColumnNumber,
jsRuntimeException.ColumnNumber.ToString(CultureInfo.InvariantCulture));
}
if (!string.IsNullOrWhiteSpace(jsRuntimeException.SourceFragment))
{
errorMessage.AppendFormatLine("{1}:{0}{0}{2}", Environment.NewLine,
Strings.ErrorDetails_SourceFragment,
jsRuntimeException.SourceFragment);
}
return errorMessage.ToString();
}
开发者ID:RichardD012,项目名称:JavaScriptEngineSwitcher.Dotnet.Unofficial,代码行数:49,代码来源:JsRuntimeErrorHelpers.cs
示例10: CombineAssetContent
protected override string CombineAssetContent(IList<IAsset> assets)
{
var contentBuilder = new StringBuilder();
string topCharset = string.Empty;
var imports = new List<string>();
int assetCount = assets.Count;
int lastAssetIndex = assetCount - 1;
for (int assetIndex = 0; assetIndex < assetCount; assetIndex++)
{
IAsset asset = assets[assetIndex];
if (EnableTracing)
{
contentBuilder.AppendFormatLine("/*#region URL: {0} */", asset.Url);
}
contentBuilder.Append(EjectCssCharsetAndImports(asset.Content, ref topCharset, imports));
if (EnableTracing)
{
contentBuilder.AppendLine();
contentBuilder.AppendLine("/*#endregion*/");
}
if (assetIndex != lastAssetIndex)
{
contentBuilder.AppendLine();
}
}
if (imports.Count > 0)
{
string importsTemplate = EnableTracing ?
"/*#region CSS Imports */{0}{1}{0}/*#endregion*/{0}{0}" : "{1}{0}";
contentBuilder.Insert(0, string.Format(importsTemplate, Environment.NewLine,
string.Join(Environment.NewLine, imports)));
}
if (!string.IsNullOrWhiteSpace(topCharset))
{
contentBuilder.Insert(0, topCharset + Environment.NewLine);
}
return contentBuilder.ToString();
}
示例11: ShowError
public static void ShowError(FrameworkElement owner, Exception exception, string formatMessage = null, params object[] args)
{
Log.Error(exception, formatMessage, args);
StringBuilder sb = new StringBuilder();
if (!string.IsNullOrEmpty(formatMessage))
sb.AppendFormatLine(formatMessage, args);
if (exception != null)
sb.Append(exception);
if (owner == null)
{
MessageBox.Show(sb.ToString(), "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
}
else
{
Window window = (Window)owner.GetRootElement();
MessageBox.Show(window, sb.ToString(), "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
示例12: Compose
/// <summary>
/// Constructs exception composing details from response, method specific error description and actual inner exception
/// </summary>
/// <param name="response">Response of failed request</param>
/// <param name="stripeErrorMessage">Method specific error description</param>
/// <param name="inner">Actual inner exception</param>
/// <returns>Composed exception</returns>
public static TaxException Compose(HttpWebResponse response, string stripeErrorMessage, Exception inner)
{
int statusCode = (int)response.StatusCode;
string responseErrMsg = string.Empty;
try
{
using(var reponseStream = response.GetResponseStream())
{
using (var responseReader = new System.IO.StreamReader(reponseStream))
{
string responseStr = responseReader.ReadToEnd();
dynamic responseObj = responseStr.JSONToDynamic();
var sb = new StringBuilder();
foreach (var item in ((JSONDataMap)responseObj.Data))
{
sb.AppendFormatLine("{0}: {1}", item.Key, item.Value);
}
responseErrMsg = sb.ToString();
}
}
}
catch (Exception)
{
// dlatushkin 2014/04/07:
// there is no way to test some cases (50X errors for example)
// so try/catch is used to swallow exception
}
string specificError = System.Environment.NewLine;
if (responseErrMsg.IsNotNullOrWhiteSpace())
specificError += StringConsts.PAYMENT_STRIPE_ERR_MSG_ERROR.Args( responseErrMsg) + System.Environment.NewLine;
specificError += stripeErrorMessage;
TaxException ex = new TaxException(specificError, inner);
return ex;
}
示例13: GetHeader
private static string GetHeader(IEnumerable<string> assemblyPaths, bool forceDueToSpecialType)
{
if (!forceDueToSpecialType && !assemblyPaths.Any())
{
return "";
}
if (!assemblyPaths.All(File.Exists))
{
return "";
}
var sb = new StringBuilder();
sb.AppendFormatLine("//****************************************************************");
sb.AppendFormatLine("// Generated by: ToTypeScriptD");
sb.AppendFormatLine("// Website: http://github.com/ToTypeScriptD/ToTypeScriptD");
sb.AppendFormatLine("// Version: {0}", System.Diagnostics.FileVersionInfo.GetVersionInfo(typeof(Render).Assembly.Location).ProductVersion);
sb.AppendFormatLine("// Date: {0}", DateTime.Now);
if (assemblyPaths.Any())
{
sb.AppendFormatLine("//");
sb.AppendFormatLine("// Assemblies:");
assemblyPaths
.Select(System.IO.Path.GetFileName)
.Distinct()
.OrderBy(s => s)
.Each(path =>
{
sb.AppendFormatLine("// {0}", System.IO.Path.GetFileName(path));
});
sb.AppendFormatLine("//");
}
sb.AppendFormatLine("//****************************************************************");
sb.AppendFormatLine();
sb.AppendFormatLine();
sb.AppendFormatLine();
return sb.ToString();
}
示例14: FormatErrorDetails
/// <summary>
/// Generates a detailed error message
/// </summary>
/// <param name="errorDetails">Error details</param>
/// <param name="sourceCode">Source code</param>
/// <param name="currentFilePath">Path to current LESS-file</param>
/// <param name="dependencies">List of dependencies</param>
/// <returns>Detailed error message</returns>
private static string FormatErrorDetails(JToken errorDetails, string sourceCode, string currentFilePath,
DependencyCollection dependencies)
{
var type = errorDetails.Value<string>("type");
var message = errorDetails.Value<string>("message");
var filePath = errorDetails.Value<string>("fileName");
if (string.IsNullOrWhiteSpace(filePath))
{
filePath = currentFilePath;
}
var lineNumber = errorDetails.Value<int>("lineNumber");
var columnNumber = errorDetails.Value<int>("columnNumber");
string newSourceCode = string.Empty;
if (string.Equals(filePath, currentFilePath, StringComparison.OrdinalIgnoreCase))
{
newSourceCode = sourceCode;
}
else
{
var dependency = dependencies.GetByUrl(filePath);
if (dependency != null)
{
newSourceCode = dependency.Content;
}
}
string sourceFragment = SourceCodeNavigator.GetSourceFragment(newSourceCode,
new SourceCodeNodeCoordinates(lineNumber, columnNumber));
var errorMessage = new StringBuilder();
if (!string.IsNullOrWhiteSpace(type))
{
errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_ErrorType, type);
}
errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_Message, message);
if (!string.IsNullOrWhiteSpace(filePath))
{
errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_File, filePath);
}
if (lineNumber > 0)
{
errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_LineNumber,
lineNumber.ToString(CultureInfo.InvariantCulture));
}
if (columnNumber > 0)
{
errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_ColumnNumber,
columnNumber.ToString(CultureInfo.InvariantCulture));
}
if (!string.IsNullOrWhiteSpace(sourceFragment))
{
errorMessage.AppendFormatLine("{1}:{0}{0}{2}", Environment.NewLine,
CoreStrings.ErrorDetails_SourceError, sourceFragment);
}
return errorMessage.ToString();
}
示例15: WriteAsyncPromiseMethods
private void WriteAsyncPromiseMethods(StringBuilder sb)
{
string genericTypeArgName;
if (IsTypeAsync(out genericTypeArgName))
{
sb.AppendLine();
Indent(sb); Indent(sb); sb.AppendFormatLine("// Promise Extension");
Indent(sb); Indent(sb); sb.AppendFormatLine("then<U>(success?: (value: {0}) => ToTypeScriptD.WinRT.IPromise<U>, error?: (error: any) => ToTypeScriptD.WinRT.IPromise<U>, progress?: (progress: any) => void): ToTypeScriptD.WinRT.IPromise<U>;", genericTypeArgName);
Indent(sb); Indent(sb); sb.AppendFormatLine("then<U>(success?: (value: {0}) => ToTypeScriptD.WinRT.IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): ToTypeScriptD.WinRT.IPromise<U>;", genericTypeArgName);
Indent(sb); Indent(sb); sb.AppendFormatLine("then<U>(success?: (value: {0}) => U, error?: (error: any) => ToTypeScriptD.WinRT.IPromise<U>, progress?: (progress: any) => void): ToTypeScriptD.WinRT.IPromise<U>;", genericTypeArgName);
Indent(sb); Indent(sb); sb.AppendFormatLine("then<U>(success?: (value: {0}) => U, error?: (error: any) => U, progress?: (progress: any) => void): ToTypeScriptD.WinRT.IPromise<U>;", genericTypeArgName);
Indent(sb); Indent(sb); sb.AppendFormatLine("done<U>(success?: (value: {0}) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;", genericTypeArgName);
}
}