当前位置: 首页>>代码示例>>C#>>正文


C# Formatter类代码示例

本文整理汇总了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;
        }
开发者ID:praetoriansentry,项目名称:tsql,代码行数:60,代码来源:Paren.cs

示例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);
 }
开发者ID:nara,项目名称:Siege,代码行数:7,代码来源:ReverseForeignRelationshipMapping.cs

示例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 ", ";
        }
开发者ID:praetoriansentry,项目名称:tsql,代码行数:35,代码来源:Comma.cs

示例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);
 }
开发者ID:praetoriansentry,项目名称:tsql,代码行数:7,代码来源:Go.cs

示例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"));
            }
        }
开发者ID:kennychou0529,项目名称:NPantaRhei,代码行数:31,代码来源:Program.cs

示例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);
        }
开发者ID:praetoriansentry,项目名称:tsql,代码行数:28,代码来源:Select.cs

示例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());
 }
开发者ID:AGRocks,项目名称:pgn.net,代码行数:8,代码来源:FormatterTest.cs

示例8: TcpConnection

        public TcpConnection(string address, int port, Formatter formatter)
        {
            if (port < 0) throw new ArgumentException();

            _address = address;
            _port = port;
            _formatter = formatter;
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:8,代码来源:TcpConnection.cs

示例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;
        }
开发者ID:praetoriansentry,项目名称:tsql,代码行数:9,代码来源:Case.cs

示例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);
        }
开发者ID:tathamoddie,项目名称:RelativeTime,代码行数:9,代码来源:FormatterTests.cs

示例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);
        }
开发者ID:praetoriansentry,项目名称:tsql,代码行数:9,代码来源:Declare.cs

示例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;
 }
开发者ID:benallred,项目名称:Icing,代码行数:16,代码来源:Stats.cs

示例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);
 }
开发者ID:praetoriansentry,项目名称:tsql,代码行数:10,代码来源:End.cs

示例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));
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:10,代码来源:FormatterTest.cs

示例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));
        }
开发者ID:rexwhitten,项目名称:Siege,代码行数:11,代码来源:ListMapping.cs


注:本文中的Formatter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。