本文整理汇总了C#中ITextFormatter类的典型用法代码示例。如果您正苦于以下问题:C# ITextFormatter类的具体用法?C# ITextFormatter怎么用?C# ITextFormatter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITextFormatter类属于命名空间,在下文中一共展示了ITextFormatter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RabbitMQ
/// <summary>
/// Adds a sink that lets you push log messages to RabbitMq
/// </summary>
public static LoggerConfiguration RabbitMQ(
this LoggerSinkConfiguration loggerConfiguration,
RabbitMQConfiguration rabbitMqConfiguration,
ITextFormatter formatter,
IFormatProvider formatProvider = null)
{
if (loggerConfiguration == null) throw new ArgumentNullException("loggerConfiguration");
if (rabbitMqConfiguration == null) throw new ArgumentNullException("rabbitMqConfiguration");
// calls overloaded extension method
return loggerConfiguration.RabbitMQ(
rabbitMqConfiguration.Hostname,
rabbitMqConfiguration.Username,
rabbitMqConfiguration.Password,
rabbitMqConfiguration.Exchange,
rabbitMqConfiguration.ExchangeType,
rabbitMqConfiguration.Queue,
rabbitMqConfiguration.DeliveryMode,
rabbitMqConfiguration.RouteKey,
rabbitMqConfiguration.Port,
rabbitMqConfiguration.VHost,
rabbitMqConfiguration.Heartbeat,
rabbitMqConfiguration.Protocol,
formatter,
formatProvider);
}
示例2: CompositeIdMap
public string CompositeIdMap(IList<Column> columns, ITextFormatter formatter)
{
var builder = new StringBuilder();
switch (_language)
{
case Language.CSharp:
builder.AppendLine("ComposedId(compId =>");
builder.AppendLine("\t\t\t\t{");
foreach (var column in columns)
{
builder.AppendLine("\t\t\t\t\tcompId.Property(x => x." + formatter.FormatText(column.Name) + ", m => m.Column(\"" + column.Name + "\"));");
}
builder.Append("\t\t\t\t});");
break;
case Language.VB:
builder.AppendLine("ComposedId(Sub(compId)");
foreach (var column in columns)
{
builder.AppendLine("\t\t\t\t\tcompId.Property(Function(x) x." + formatter.FormatText(column.Name) + ", Sub(m) m.Column(\"" + column.Name + "\"))");
}
builder.AppendLine("\t\t\t\tEnd Sub)");
break;
}
return builder.ToString();
}
示例3: OutputSink
public OutputSink(Func<IOutput> outputProvider, ITextFormatter textFormatter, Func<IOutputLogFilter> outputLogFilterProvider = null)
{
if (textFormatter == null) throw new ArgumentNullException("textFormatter");
_textFormatter = textFormatter;
_outputProvider = outputProvider;
_outputLogFilterProvider = outputLogFilterProvider;
}
示例4: Format
public override string Format(IPostParsingContext context, ITextFormatter<IPostParsingContext> formatter)
{
if(this.Name.ToLower() == "q" || this.Name.ToLower() == "quote") {
return "";
} else if(this.Name.ToLower() == "code") {
return "[code]" + this.InnerBBCode + "[/code]";
} else {
string name = this.Name;
if(name.ToLower() == "uploadimage") name = "uploadLink";
var sb = new StringBuilder();
sb.Append("[");
sb.Append(name);
if(this.Default != null && this.Default != "") {
sb.Append("='");
sb.Append(this.Default.Replace("'", "''"));
sb.Append("'");
} else {
foreach(var attribute in this.Attributes) {
sb.Append(" ");
sb.Append(attribute.Key);
sb.Append("='");
sb.Append(attribute.Value.Replace("'", "''"));
sb.Append("'");
}
}
sb.Append("]");
if(this.RequireClosingTag) {
sb.Append(this.GetInnerHTML(context, formatter));
sb.Append("[/");
sb.Append(name);
sb.Append("]");
}
return sb.ToString();
}
}
示例5: FileSink
public FileSink(string path, ITextFormatter textFormatter)
{
if (path == null) throw new ArgumentNullException("path");
if (textFormatter == null) throw new ArgumentNullException("textFormatter");
_textFormatter = textFormatter;
_output = new StreamWriter(System.IO.File.Open(path, FileMode.Append, FileAccess.Write, FileShare.Read));
}
示例6: XUnitTestOutputSink
public XUnitTestOutputSink(ITestOutputHelper testOutputHelper, ITextFormatter textFormatter)
{
if (testOutputHelper == null) throw new ArgumentNullException("testOutputHelper");
if (textFormatter == null) throw new ArgumentNullException("textFormatter");
_output = testOutputHelper;
_textFormatter = textFormatter;
}
示例7: Format
public override string Format(IPostParsingContext context, ITextFormatter<IPostParsingContext> formatter)
{
string inner = this.GetInnerHTML(context, formatter).TrimHtml();
if(inner == "") return "";
string marker = this.Default;
if(marker == null) marker = "Quote:";
return "<blockquote><div class=\"quotetitle\">" + marker + "</div><div class=\"quotecontent\">" + inner + "</div></blockquote>";
}
示例8: DummyRollingFile
public static LoggerConfiguration DummyRollingFile(
this LoggerSinkConfiguration loggerSinkConfiguration,
ITextFormatter formatter,
string pathFormat,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum)
{
return loggerSinkConfiguration.Sink(new DummyRollingFileSink(), restrictedToMinimumLevel);
}
示例9: Format
public override string Format(IPostParsingContext context, ITextFormatter<IPostParsingContext> formatter)
{
var upload = dataobjects.Upload.LoadById(int.Parse(this.DefaultOrValue));
var name = this.Safe(upload.filename);
if(this.Default != null) {
name = this.GetInnerHTML(context, formatter);
}
return "<a href=\"/Upload/Info/" + upload.id.ToString() + "/\">" + name + "</a>";
}
示例10: SizeLimitedFileSink
public SizeLimitedFileSink(ITextFormatter formatter, TemplatedPathRoller roller, long fileSizeLimitBytes,
RollingLogFile rollingLogFile, Encoding encoding = null)
{
this.formatter = formatter;
this.roller = roller;
this.fileSizeLimitBytes = fileSizeLimitBytes;
this.EnableLevelLogging = roller.PathIncludesLevel;
this.output = OpenFileForWriting(roller.LogFileDirectory, rollingLogFile, encoding ?? Encoding.UTF8);
}
示例11: Format
public override string Format(IPostParsingContext context, ITextFormatter<IPostParsingContext> formatter)
{
var url = this.url;
var name = this.Safe(url.title);
if(this.Default != null) {
name = this.GetInnerHTML(context, formatter);
}
return string.Format("<a href=\"{0}\">{1}</a>", url.canonical, url.title);
}
示例12: Format
public override string Format(IPostParsingContext context, ITextFormatter<IPostParsingContext> formatter)
{
string rawUrl = this.DefaultOrValue;
string title = null;
if(rawUrl.ToLower() != this.InnerText.ToLower()) {
title = this.GetInnerHTML(context, formatter);
}
return UrlProcessor.ProcessLink(rawUrl, title, false);
}
示例13: Format
public override string Format(IPostParsingContext context, ITextFormatter<IPostParsingContext> formatter)
{
var urlInfo = UrlProcessor.Process(this.InnerText);
if (urlInfo.isLocal && urlInfo.relativeUrl.StartsWith("/user/upload/")) {
return "<f:img><f:src>" + urlInfo.relativeUrl + "</f:src><f:alt>" + urlInfo.relativeUrl + "</f:alt></f:img>";
} else {
return "<a href=\"" + urlInfo.relativeUrl + "\">" + urlInfo.relativeUrl + "</a>";
}
}
示例14: RabbitMQSink
public RabbitMQSink(RabbitMQConfiguration configuration,
ITextFormatter formatter,
IFormatProvider formatProvider)
: base(configuration.BatchPostingLimit, configuration.Period)
{
_formatter = formatter ?? new RawFormatter();
_formatProvider = formatProvider;
_client = new RabbitMQClient(configuration);
}
示例15: AzureEventHubSink
/// <summary>
/// Construct a sink that saves log events to the specified EventHubClient.
/// </summary>
/// <param name="eventHubClient">The EventHubClient to use in this sink.</param>
/// <param name="partitionKey">PartitionKey to group events by within the Event Hub.</param>
/// <param name="formatter">Provides formatting for outputting log data</param>
public AzureEventHubSink(
EventHubClient eventHubClient,
string partitionKey,
ITextFormatter formatter)
{
_eventHubClient = eventHubClient;
_partitionKey = partitionKey;
_formatter = formatter;
}