private static SmartFormatter GetFormatterWithRegisteredTemplates(CaseSensitivityType caseSensitivity) { var templates = new TemplateFormatter { CanAutoDetect = false }; var smart = Smart.CreateDefaultSmartFormat(new SmartSettings { CaseSensitivity = caseSensitivity }); smart.AddExtensions(templates); templates.Register("firstLast", "{First} {Last}"); templates.Register("lastFirst", "{Last}, {First}"); templates.Register("FIRST", "{First.ToUpper}"); templates.Register("last", "{Last.ToLower}"); if (smart.Settings.CaseSensitivity == CaseSensitivityType.CaseSensitive) { templates.Register("LAST", "{Last.ToUpper}"); } templates.Register("NESTED", "{:t:FIRST} {:t:last}"); return(smart); }
private static SmartFormatter GetFormatterWithRegisteredResource(CaseSensitivityType caseSensitivity = CaseSensitivityType.CaseSensitive, FormatErrorAction formatErrorAction = FormatErrorAction.ThrowError) { var localizationFormatter = new LocalizationFormatter { CanAutoDetect = false }; var smart = Smart.CreateDefaultSmartFormat(new SmartSettings { CaseSensitivity = caseSensitivity, Localization = { LocalizationProvider = new LocalizationProvider(true, LocTest1.ResourceManager) { FallbackCulture = null, ReturnNameIfNotFound= false } }, Formatter = { ErrorAction = formatErrorAction } }) .AddExtensions(localizationFormatter) .AddExtensions(new PluralLocalizationFormatter()); return(smart); }