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


C# Formatter.Format方法代码示例

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


在下文中一共展示了Formatter.Format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: It_Should_Not_Be_null

 public void It_Should_Not_Be_null()
 {
     _objectsToFormat = new List<DummyObject>();
     for (int i = 0; i < _numberOfObjects; i++)
     {
         _objectsToFormat.Add(new DummyObject());
     }
     _formatter = new Formatter<DummyObject>();
     try
     {
         _formatter.Format(_objectsToFormat);
         Assert.Fail("Expected NoFormatSpecificationException to be thrown");
     }
     catch (NoFormatSpecificationException)
     {
         // Expect NoFormatSpecificationException to be thrown.
     }
 }
开发者ID:mastoj,项目名称:TJ.FileFormatter,代码行数:18,代码来源:FormatterTests.cs

示例4: Then_Fixed_Length_Should_Be_Applied_To_The_Fields

 public void Then_Fixed_Length_Should_Be_Applied_To_The_Fields()
 {
     var dummyObjects = new List<DummyObject>();
     for (int i = 0; i < 10; i++)
     {
         dummyObjects.Add(new DummyObject() { SomeInt = i, SomeString = "Str" + i});
     }
     var formatter = new Formatter<DummyObject>()
         .With(y => y.SomeInt, 0, 5, y => y.ToString().PadLeft(5, '0'))
         .With(y => y.SomeString, 5, 5, y => y.PadRight(5, ' '));
     var result = formatter.Format(dummyObjects);
     for (int i = 0; i < dummyObjects.Count; i++)
     {
         string expected = i.ToString().PadLeft(5, '0') + ("Str" + i).PadRight(5, ' ');
         string actual = result.ElementAt(i);
         Assert.AreEqual(expected, actual);
     }
 }
开发者ID:mastoj,项目名称:TJ.FileFormatter,代码行数:18,代码来源:FormatterTests.cs

示例5: CommentedObjectPropertyTextShouldNotBeChanged

 public void CommentedObjectPropertyTextShouldNotBeChanged()
 {
     const string TEMPLATE = "abcd'\\$\\{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

示例6: TwoObjectPropertiesTextTemplateShouldBeChanged

 public void TwoObjectPropertiesTextTemplateShouldBeChanged()
 {
     const string TEMPLATE = "abcd${Text}efgh${Text}";
     const string FORMATTED = "abcd12345efgh12345";
     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

示例7: HandleNestedIncludeWithParentDirs

 public void HandleNestedIncludeWithParentDirs()
 {
     var formatter = new Formatter("<sharp:include file='SharpTags/withparent.htm'/>").Parse();
     Assert.That(formatter.Format(new TagModel(new Hashtable())),
                 Is.EqualTo("parent aa"));
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:6,代码来源:IncludeTest.cs

示例8: HandOverVariableScopeNested

        public void HandOverVariableScopeNested()
        {
            var some = new Hashtable();
            some.Add("a", "##");

            var table = new Hashtable();
            table.Add("some", some);

            var formatter = new Formatter("<sharp:include file='SharpTags/b.htm'/>").Parse();
            Assert.That(formatter.Format(new TagModel(table)),
                        Is.EqualTo("bb##bb"));
        }
开发者ID:rslijp,项目名称:sharptiles,代码行数:12,代码来源:IncludeTest.cs

示例9: Then_The_Static_Field_Should_Be_Printed

 public void Then_The_Static_Field_Should_Be_Printed()
 {
     var formatter = new Formatter<DummyObject>()
         .With("Hello", 0)
         .With(y => y.SomeInt, 1, 5, y => y.ToString("00000"))
         .With("World!", 2)
         .WithDelimiter(";");
     var result = formatter.Format(_objectsToFormat);
     for (int i = 0; i < _objectsToFormat.Count; i++)
     {
         var expected = "Hello;" + _objectsToFormat[i].SomeInt.ToString("00000") + ";World!";
         Assert.AreEqual(expected, result.ElementAt(i));
     }
 }
开发者ID:mastoj,项目名称:TJ.FileFormatter,代码行数:14,代码来源:FormatterTests.cs

示例10: And_Prefix_Is_Used_It_Should_Be_Applied_At_Start_Of_Row

 public void And_Prefix_Is_Used_It_Should_Be_Applied_At_Start_Of_Row()
 {
     var prefix = "ThisIsAPrefix";
     var formatter = new Formatter<DummyObject>()
         .With(y => y.SomeInt, 1, 5, y => y.ToString("00000"))
         .With(y => y.SomeString, 2, 6, y => y.ToString().PadLeft(6, '_'))
         .WithLinePrefix(prefix)
         .WithDelimiter(";");
     var result = formatter.Format(_objectsToFormat);
     foreach (var item in result)
     {
         Assert.IsTrue(item.StartsWith(prefix + ";"));
     }
 }
开发者ID:mastoj,项目名称:TJ.FileFormatter,代码行数:14,代码来源:FormatterTests.cs

示例11: It_Should_Throw_Format_Gap_Exception

 public void It_Should_Throw_Format_Gap_Exception()
 {
     var formatter = new Formatter<DummyObject>()
         .With(y => y.SomeInt, 0, 4, y => y.ToString())
         .With(y => y.SomeString, 5, 3, y => y.ToString());
     try
     {
         IEnumerable<DummyObject> items = new List<DummyObject>();
         formatter.Format(items);
         Assert.Fail("Should throw MissingFormatSpecificationException");
     }
     catch (FormatGapException)
     {
     }
 }
开发者ID:mastoj,项目名称:TJ.FileFormatter,代码行数:15,代码来源:FormatterTests.cs

示例12: Setting_Local_Affects_Formatting_Of_Number_EN_After_Cout

 public void Setting_Local_Affects_Formatting_Of_Number_EN_After_Cout()
 {
     const string TEMPLATE = "<fmt:setLocale value='en-GB' scope='Page'/><c:out value=\"${'0.00'+'1.00'}%\"/>";
     const string FORMATTED = "1.00%";
     var model = new TestModel();
     model.Text = "";
     var formatter = new Formatter(TEMPLATE).Parse();
     string formatted = formatter.Format(model);
     Assert.That(formatted, Is.EqualTo(FORMATTED));
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:10,代码来源:FormatterTest.cs

示例13: Setting_Empty_String_Should_Be_Parsed_Correctly

 public void Setting_Empty_String_Should_Be_Parsed_Correctly()
 {
     const string TEMPLATE = "<c:set value='' var='Text' scope='Model'/>";
     var model = new TestModel();
     model.Text = "aaa";
     var formatter = new Formatter(TEMPLATE).Parse();
     formatter.Format(model);
     Console.WriteLine($"[{model.Text}]");
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:9,代码来源:FormatterTest.cs

示例14: PlainTextTempalteShouldNotBeChanged

 public void PlainTextTempalteShouldNotBeChanged()
 {
     const string TEMPLATE = "abcdefgh";
     var formatter = new Formatter(TEMPLATE).Parse();
     string formatted = formatter.Format(new object());
     Assert.That(formatted, Is.EqualTo(TEMPLATE));
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:7,代码来源:FormatterTest.cs

示例15: ParseOfNonCommandTagsShouldNotDistrubtFormatting

 public void ParseOfNonCommandTagsShouldNotDistrubtFormatting()
 {
     const string TEMPLATE = "<a/>bcd${Text}slk";
     const string FORMATTED = "<a/>bcd12345slk";
     var model = new TestModel();
     model.Text = "12345";
     var formatter = new Formatter(TEMPLATE).Parse();
     string formatted = formatter.Format(model);
     Assert.That(formatted, Is.EqualTo(FORMATTED));
     Assert.That(formatter.ParsedTemplate.Count, Is.EqualTo(3));
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:11,代码来源:FormatterTest.cs


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