• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Formatter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Formatter的典型用法代码示例。如果您正苦于以下问题:C# Formatter类的具体用法?C# Formatter怎么用?C# Formatter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Formatter类属于命名空间,在下文中一共展示了Formatter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: SerialiseDataType

        /// <summary>
        /// Format a data type into a string in a localisation namespace
        /// </summary>
        /// <param name="dataType">The data type to format</param>
        /// <param name="elementName">The name of the element</param>
        public static void SerialiseDataType(IGraphable dataType, XmlWriter xmlWriter, string elementName, string localNamespace)
        {
            if (dataType != null)
            {
                xmlWriter.WriteStartElement(elementName, localNamespace);
                Formatter fmtr = new Formatter();
                fmtr.GraphAides.Add(typeof(MARC.Everest.Formatters.XML.Datatypes.R1.Formatter));
                fmtr.GraphObject(xmlWriter, dataType);

                xmlWriter.WriteEndElement();
            }
        }
开发者ID:Dunmail,项目名称:cdaapi_core,代码行数:17,代码来源:XMLFormatter.cs


示例17: Interpret

        public override string Interpret(ref Formatter.ParseUnit pu)
        {
            if (this.IsJoin(pu))
            {
                return this.GetNewLine(pu) + this.GetNewLine(pu) + pu.token.Value.Text.ToUpper();

            }
            else
            {
                return pu.token.Value.Text.ToUpper();
            }
        }
开发者ID:praetoriansentry,项目名称:tsql,代码行数:12,代码来源:Right.cs


示例18: FormatWithPhase1And2

        public string FormatWithPhase1And2(Formatter formatter)
        {
            var content = this.GetContent();

            if (content == null)
            {
                this.formatPhase1Cache = string.Empty;
                this.formatPhase3Cache = string.Empty;
                this.links = new string[0];
            }

            return this.formatPhase1Cache ?? (this.formatPhase1Cache = FormattingPipeline.FormatWithPhase1And2(formatter, content.Content, false, FormattingContext.PageContent, this.page, out this.links));
        }
开发者ID:Pathfinder-Fr,项目名称:WikiXmlExport,代码行数:13,代码来源:WikiPage.cs


示例19: Provider

        public Provider(ApiSchema schema, string address, int port, string phone, ITelegramPersist persist)
        {
            _address = address;
            _port = port;
            _phone = phone;
            _persist = persist;
            _formatter = new Formatter();
            Combinator.Setup(schema, _formatter);

            _settings = LoadSettings();

            _connection = new TcpConnection(_address, _port, _formatter);
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:13,代码来源:Provider.cs


示例20: Interpret

 public override string Interpret(ref Formatter.ParseUnit pu)
 {
     if (this.IsToken(pu.token.Value))
     {
         Console.WriteLine(pu.token.Value.Type);
         return this.GetNewLine(pu) + pu.token.Value.Text.ToUpper();
     }
     if (this.shouldCapitalize(pu.token.Value.Type))
     {
         return pu.token.Value.Text.ToUpper();
     }
     return pu.token.Value.Text;
 }
开发者ID:praetoriansentry,项目名称:tsql,代码行数:13,代码来源:Default.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Formatting类代码示例发布时间:2022-05-24
下一篇:
C# FormatCompiler类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap