Questions tagged [smartformat.net]

SmartFormat is a string composition library written in C# (.NET 3.5) that can format data into a string with a minimal, intuitive syntax. It uses extensions to provide named placeholders, pluralisation, gender conjugation, and time and list formatting.

Text copied from https://github.com/scottrippey/SmartFormat.NET/wiki

SmartFormat is a string composition library written in C# (.NET 3.5) that can format data into a string with a minimal, intuitive syntax. It uses extensions to provide named placeholders, pluralisation, gender conjugation, and time and list formatting.trong text

For background see Custom Formatting in .NET - Enhancing String.Format to all new levels!

7 questions
2
votes
2 answers

How to use C# extension methods with SmartFormat reflection syntax?

Is it possible to make the following example work with SmartFormat.NET? void Main() { Dictionary ps = new Dictionary(); ps["Name"] = "Niels"; Smart.Format("{Name.Foo} is my name", ps).Dump(); …
Niels Bosma
  • 11,758
  • 29
  • 89
  • 148
2
votes
1 answer

How to use Properties of an item in a collection using SmartFormat.NET

I am trying to use SmartFormat and I have an issue with it. I am using the following format "{SelectedUsers:| {User.FirstName} is selected for '{Job.Summary} job. ', }" and I am expecting that the output will be like following for each item. (If the…
adeel41
  • 3,123
  • 1
  • 29
  • 25
2
votes
1 answer

SmartFormat.NET nested placeholders in List format error

I am trying to test out the functionality of SmartFormat.NET, and I am having trouble trying to format a list of view model items. According to this exchange, what I am trying to accomplish should be possible with nested placeholders. Here is the…
mao47
  • 967
  • 10
  • 25
1
vote
2 answers

SmartFormat best way to serialize a dictionary

I have a data object with an dictionary. Now I want to serialize this dictionary to a json string. Is it possible to do this inside the template? public string GenerateTest() { Dictionary dataDictionary = new Dictionary
atheos
  • 21
  • 4
0
votes
1 answer

SmartFormat - Override format method

I want to override Format method of SmartFormat.SmartFormatter class. Can anyone give me a sample or any idea on how to do that?
samssagar
  • 1
  • 4
0
votes
1 answer

Validate Smart Format object against the token available in the string

I am trying to validate the smart format object against the token present in the string. Sample:- object obj = {"Id": "1", "RegNo": "REG123"} Smart.Format("Your Id - {Id} for registration - {RegNo}", obj); If I do not pass RegNo property/value…
samssagar
  • 1
  • 4
0
votes
2 answers

Smart.Format version 2.5.0 error once upgraded

I just upgraded from smart.format 2.4.2 to 2.5.0. I have the following in production since 2018: attFilePath = "C:/dev/template.html" //HTML TEMPLATE WITH PLACEHOLDERS IN IT LIKE, Welcome…
Ray
  • 483
  • 4
  • 17