本文整理汇总了C#中Formatter类的典型用法代码示例。如果您正苦于以下问题:C# Formatter类的具体用法?C# Formatter怎么用?C# Formatter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Formatter类属于命名空间,在下文中一共展示了Formatter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Interpret
public override string Interpret(ref Formatter.ParseUnit pu)
{
if (pu.token.Value.Type == "(")
{
Token t;
bool isCreate = false;
try
{
t = pu.clauseStack.Peek();
if (t.Type == "TOKEN_CREATE")
{
pu.indentDepth = 1;
isCreate = true;
}
}
catch (Exception) { }
pu.clauseStack.Push(pu.token.Value);
if (isCreate)
{
return pu.token.Value.Text + this.GetNewLine(pu);
}
}
else
{
Token t = pu.clauseStack.Peek();
if (t.Type == "TOKEN_SELECT" && pu.clauseStack.Count > 1)
{
pu.clauseStack.Pop(); // Take a select off the stack
if (pu.clauseStack.Peek().Type == "(")
{
pu.clauseStack.Pop(); // Remove the wrapping parentheis
pu.indentDepth = pu.indentDepth - 1;
return this.GetNewLine(pu) + pu.token.Value.Text + " ";
}
}
else if (t.Type == "(" && pu.clauseStack.Count > 1)
{
pu.clauseStack.Pop();
if (pu.clauseStack.Peek().Type == "TOKEN_CREATE")
{
pu.clauseStack.Pop();
pu.indentDepth = pu.indentDepth - 1;
return this.GetNewLine(pu) + pu.token.Value.Text + " ";
}
}
else
{
pu.clauseStack.Pop();
}
}
if (pu.token.Value.Type == ")")
{
return pu.token.Value.Text + " ";
}
return pu.token.Value.Text;
}
示例2: ReverseForeignRelationshipMapping
public ReverseForeignRelationshipMapping(PropertyInfo property, Type type, Type parentType, Formatter<PropertyInfo> keyFormatter)
: base(property)
{
this.type = type;
this.parentType = parentType;
this.ColumnName = keyFormatter.Format(property);
}
示例3: Interpret
public override string Interpret(ref Formatter.ParseUnit pu)
{
Token t = null;
Token t2 = null;
try
{
t = pu.clauseStack.Peek();
if (t.Type == "(")
{
pu.clauseStack.Pop();
try
{
t2 = pu.clauseStack.Peek();
}
finally
{
pu.clauseStack.Push(t);
}
}
}
catch (Exception)
{
return ", ";
}
if (t2 != null && t2.Type == "TOKEN_CREATE")
{
return "," + this.GetNewLine(pu);
}
if (t.Type == "TOKEN_SELECT" || t.Type == "TOKEN_DECLARE")
{
return "," + this.GetNewLine(pu);
}
return ", ";
}
示例4: Interpret
public override string Interpret(ref Formatter.ParseUnit pu)
{
// go statements reset a bunch of stuff
pu.clauseStack.Clear();
pu.indentDepth = 0;
return this.GetNewLine(pu) + pu.token.Value.Text.ToUpper() + this.GetNewLine(pu);
}
示例5: Main
static void Main(string[] args)
{
var textfileadapter = new TextfileAdapter();
var formatter = new Formatter();
var config = new FlowRuntimeConfiguration()
.AddStreamsFrom("TelegramProblem.run.flow", Assembly.GetExecutingAssembly())
.AddAction<string>("read", textfileadapter.Read).MakeAsync()
.AddAction<string>("write", textfileadapter.Write, true)
.AddAction<string, string>("decompose", formatter.Decompose)
.AddAction<string, string>("concatenate", formatter.Concatenate)
.AddAction<Tuple<string, string>>("textfileadapter_config", textfileadapter.Config)
.AddAction<int>("formatter_config", formatter.Config);
using(var fr = new FlowRuntime(config))
{
fr.UnhandledException += Console.WriteLine;
fr.Process(".configFilenames", new Tuple<string,string>("source.txt", "target.txt"));
fr.Process(".configLineWidth", 60);
fr.Process(".run");
fr.WaitForResult();
Console.WriteLine(File.ReadAllText("target.txt"));
}
}
示例6: Interpret
public override string Interpret(ref Formatter.ParseUnit pu)
{
Token t;
try
{
t = pu.clauseStack.Peek();
if (!this.isUnion(pu) && (t.Type == "TOKEN_SELECT" || t.Type == "TOKEN_UPDATE" || t.Type == "TOKEN_DELETE" || t.Type == "TOKEN_INSERT" || t.Type == "TOKEN_DECLARE"))
{
pu.clauseStack.Clear();
pu.indentDepth = 0;
}
}
catch (Exception)
{
}
bool shouldIncreaseIndent = this.shouldIncreaseIndent(pu);
pu.clauseStack.Push(pu.token.Value);
if (shouldIncreaseIndent && !this.isUnion(pu))
{
pu.indentDepth = pu.indentDepth + 1;
}
return this.FormatOwnLine(pu);
}
示例7: Format_should_accept_TextWriter
public void Format_should_accept_TextWriter()
{
var sut = new Formatter();
var writer = new StringWriter();
writer.NewLine = "\n";
sut.Format(_testGame, writer);
Assert.AreEqual(TestGameString, writer.ToString());
}
示例8: TcpConnection
public TcpConnection(string address, int port, Formatter formatter)
{
if (port < 0) throw new ArgumentException();
_address = address;
_port = port;
_formatter = formatter;
}
示例9: Interpret
public override string Interpret(ref Formatter.ParseUnit pu)
{
pu.clauseStack.Push(pu.token.Value);
string returnString = this.GetNewLine(pu) + pu.token.Value.Text.ToUpper();
pu.indentDepth = pu.indentDepth + 1;
return returnString;
}
示例10: Formatter_Format_ShouldReturnExpectedValues
public void Formatter_Format_ShouldReturnExpectedValues()
{
var timeSpan = TimeSpan.Parse((string)TestContext.DataRow["timeSpan"]);
var formattedValue = (string)TestContext.DataRow["formattedValue"];
var actual = new Formatter().Format(timeSpan);
Assert.AreEqual(formattedValue, actual, "input: " + timeSpan);
}
示例11: Interpret
public override string Interpret(ref Formatter.ParseUnit pu)
{
pu.clauseStack.Clear();
pu.indentDepth = 0;
pu.clauseStack.Push(pu.token.Value);
return this.FormatOwnLine(pu);
}
示例12: Stats
/// <summary>
/// Initializes a new instance of the <see cref="Stats"/> class.
/// </summary>
/// <param name="expectedIterations">The number of expected iterations.</param>
/// <param name="formatter">The value formatter.</param>
/// <param name="averageFormatter">The average value formatter.</param>
public Stats(int expectedIterations, Formatter formatter, Formatter averageFormatter)
{
ExpectedIterations = expectedIterations;
TotalIterations = 0;
Total = 0;
Min = double.MaxValue;
Max = double.MinValue;
Format = formatter;
FormatAverage = averageFormatter;
}
示例13: Interpret
public override string Interpret(ref Formatter.ParseUnit pu)
{
Token t = pu.clauseStack.Peek();
if (t.Type == "TOKEN_BEGIN" || t.Type == "TOKEN_CASE")
{
pu.clauseStack.Pop();
pu.indentDepth -= 1;
}
return this.GetNewLine(pu) + pu.token.Value.Text.ToUpper() + this.GetNewLine(pu);
}
示例14: CommentedCodeShouldBeFilteredOut
public void CommentedCodeShouldBeFilteredOut()
{
const string TEMPLATE = "abcd'<%--<mdc:test />--%>\\$\\{Text\\}'efgh${Text}";
const string FORMATTED = "abcd'${Text}'efgh12345";
var model = new TestModel();
model.Text = "12345";
var formatter = new Formatter(TEMPLATE).Parse();
string formatted = formatter.Format(model);
Assert.That(formatted, Is.EqualTo(FORMATTED));
}
示例15: Build
public override void Build(DomainMapper masterMap, Formatter<PropertyInfo> formatter)
{
base.Build(masterMap, formatter);
var mappedType = masterMap.For(Property.PropertyType.GetGenericArguments()[0]);
if(!mappedType.SubMappings.Any()) throw new Exception(string.Format("No mappings found type {0}", Property.PropertyType.GetGenericArguments()[0]));
var foreignKey = mappedType.SubMappings.OfType<IdMapping>().First().Property;
this.foreignRelationshipMapping = new ReverseForeignRelationshipMapping(Property, type, parentType, foreignKey, formatter);
masterMap.For(type).Map(mapping => mapping.MapForeignRelationship(masterMap, Property, type, formatter));
}