public static SmartFormatter CreateDefaultSmartFormat() { // Register all default extensions here: var result = new SmartFormatter(); // Add all extensions: // Note, the order is important; the extensions // will be executed in this order: var listFormatter = new ListFormatter(result); result.AddExtensions( (ISource)listFormatter, new ReflectionSource(result), new DictionarySource(result), new XmlSource(result), // These default extensions reproduce the String.Format behavior: new DefaultSource(result) ); result.AddExtensions( (IFormatter)listFormatter, new PluralLocalizationFormatter("en"), new ConditionalFormatter(), new TimeFormatter("en"), new XElementFormatter(), new ChooseFormatter(), new DefaultFormatter() ); return(result); }
public static SmartFormatter CreateDefaultSmartFormat() { // Register all default extensions here: var result = new SmartFormatter(); // Add all extensions: // Note, the order is important; the extensions // will be executed in this order: var listFormatter = new ListFormatter(result); result.AddExtensions( (ISource)listFormatter, new ReflectionSource(result), new DictionarySource(result), // These default extensions reproduce the String.Format behavior: new DefaultSource(result) ); result.AddExtensions( (IFormatter)listFormatter, new PluralLocalizationFormatter("en"), new ConditionalFormatter(), new TimeFormatter("en"), new DefaultFormatter() ); return result; }
static Localizer() { formatter = new SmartFormatter(); var listFormatter = new ListFormatter(formatter); formatter.AddExtensions( listFormatter, new DefaultSource(formatter) ); formatter.AddExtensions( listFormatter, new PluralLocalizationFormatter("en"), new ChooseFormatter(), new DefaultFormatter() ); }
public static SmartFormatter CreateDefaultSmartFormat() { // Register all default extensions here: var formatter = new SmartFormatter(); // Add all extensions: // Note, the order is important; the extensions // will be executed in this order: var listFormatter = new ListFormatter(formatter); // sources for specific types must be in the list before ReflectionSource formatter.AddExtensions( (ISource)listFormatter, // ListFormatter MUST be first new DictionarySource(formatter), new ValueTupleSource(formatter), new SmartObjectsSource(formatter), new JsonSource(formatter), new XmlSource(formatter), new ReflectionSource(formatter), // The DefaultSource reproduces the string.Format behavior: new DefaultSource(formatter) ); formatter.AddExtensions( (IFormatter)listFormatter, new PluralLocalizationFormatter("en"), new ConditionalFormatter(), new TimeFormatter("en"), new XElementFormatter(), new ChooseFormatter(), new SubStringFormatter(), new DefaultFormatter() ); return(formatter); }
public static SmartFormatter CreateDefaultSmartFormat() { // Register all default extensions here: var result = new SmartFormatter(); return result .AddExtensions( new PluralLocalizationFormatter("en"), new ListFormatter(result), new ConditionalFormatter(), new TimeFormatter("en"), new ReflectionSource(result), new DictionarySource(result), new DefaultSource(result), new DefaultFormatter() ); }