예제 #1
0
        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);
        }
예제 #2
0
		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;
		}
예제 #3
0
        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()
            );
        }
예제 #4
0
        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);
        }
예제 #5
0
파일: Smart.cs 프로젝트: vhenzl/SmartFormat
 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()
         );
 }