/// <summary> /// Setup class for returning plural names /// </summary> static IPluralizationApi InitializeApi() { var builder = new PluralizationApiBuilder(); builder.AddEnglishProvider(); return(builder.Build()); }
/// <summary> /// 将单词转换为单数形式 /// </summary> /// <param name="str"></param> /// <returns></returns> public static string ToSingularize(this string str) { var builder = new PluralizationApiBuilder(); builder.AddEnglishProvider(); return(builder.Build().Singularize(str, new CultureInfo("en-US"))); }
static StringExtensions() { var builder = new PluralizationApiBuilder(); builder.AddEnglishProvider(); _pluralizationApi = builder.Build(); }
public JsonClassGenerator() { var builder = new PluralizationApiBuilder(); builder.AddEnglishProvider(); pluralizationService = builder.Build(); CultureInfo = new CultureInfo("en-US"); }
public PluralizationServiceInstance(CultureInfo cultureInfo) { var builder = new PluralizationApiBuilder(); builder.AddEnglishProvider(); _api = builder.Build(); _cultureInfo = cultureInfo; }
static PluralizationServiceInstance() { var builder = new PluralizationApiBuilder(); builder.AddEnglishProvider(); Api = builder.Build(); CultureInfo = new CultureInfo("en-US"); }
public static string ConvertToPlural(this string value) { // @todo improve this to singleton var builder = new PluralizationApiBuilder(); builder.AddEnglishProvider(); var api = builder.Build(); return(!api.IsPlural(value) ? api.Pluralize(value) : value); }
public StemmingService() { BuildStemmingDictionary(); var builder = new PluralizationApiBuilder(); builder.AddEnglishProvider(); Api = builder.Build(); CultureInfo = new CultureInfo("en-US"); }
/// <summary> /// Singleton creator of the Pluralization system /// </summary> static Pluralizer() { cultureInfo = new CultureInfo("en-US"); lazyPluralizer = new Lazy <IPluralizationApi>(() => { var builder = new PluralizationApiBuilder(); builder.AddEnglishProvider(); return(builder.Build()); }); }
// ******************************************************************* // Public methods. // ******************************************************************* #region Public methods /// <summary> /// This method configures a <see cref="PluralizationApiBuilder"/> to use /// an english meta-data provider at runtime. /// </summary> /// <param name="builder">The builder to use for the operation.</param> /// <returns>An <see cref="IPluralizationSource"/> for configuration /// purposes.</returns> public static IPluralizationSource AddEnglishProvider( this PluralizationApiBuilder builder ) { // Create the source instance. var source = new EnglishMetaDataSource(); // Add the source to the builder. builder.AddSource(source); // Return the source instance for configuration purposes. return(source); }
static PluralizationProvider() { // Set the culture culture = new CultureInfo("en-US"); // Create the singleton instance lazyPluralApi = new Lazy <IPluralizationApi>(() => { var builder = new PluralizationApiBuilder(); builder.AddEnglishProvider(); return(builder.Build()); }); }
public string GenerateTypeScript(IEnumerable <Type> types) { var typeDefinitions = types .ResolveRelations() .ResolveConfigs() .ResolveNames() .ResolveDuplications(); var processDefinitions = typeDefinitions.Where(x => x.ProcessConfig?.OutputType != OutputType.None); var nameConvertor = new NameConvertor(typeDefinitions); var valueConvertor = new ValueConvertor(typeDefinitions, nameConvertor); var codeGeneratorFactory = new CodeGeneratorFactory(nameConvertor, valueConvertor); var codeBuilder = new StringBuilder(); var pluralizationBuilder = new PluralizationApiBuilder(); pluralizationBuilder.AddEnglishProvider(); var pluralizationApi = pluralizationBuilder.Build(); var cultureInfo = new CultureInfo("en-US"); codeBuilder.Append(_assemblyHelper.GetAssemblyContent()); Enum.GetValues(typeof(OutputType)).Cast <OutputType>().ToList() .ForEach(x => { var codeGenerator = codeGeneratorFactory.GetInstance(x); if (codeGenerator != null) { var sectionName = pluralizationApi.Pluralize(x.ToString(), cultureInfo); codeBuilder.Append(_assemblyHelper.GetSectionSeparator(sectionName)); processDefinitions.GetProcessingTypes(x).ForEach(t => codeBuilder.AppendLine(codeGenerator.Generate(t)) ); } }); return(codeBuilder.ToString()); }