/// <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")));
        }
Exemple #2
0
        static StringExtensions()
        {
            var builder = new PluralizationApiBuilder();

            builder.AddEnglishProvider();
            _pluralizationApi = builder.Build();
        }
Exemple #3
0
        /// <summary>
        /// Setup class for returning plural names
        /// </summary>
        static IPluralizationApi InitializeApi()
        {
            var builder = new PluralizationApiBuilder();

            builder.AddEnglishProvider();
            return(builder.Build());
        }
        public JsonClassGenerator()
        {
            var builder = new PluralizationApiBuilder();

            builder.AddEnglishProvider();
            pluralizationService = builder.Build();
            CultureInfo          = new CultureInfo("en-US");
        }
Exemple #5
0
        public PluralizationServiceInstance(CultureInfo cultureInfo)
        {
            var builder = new PluralizationApiBuilder();

            builder.AddEnglishProvider();

            _api         = builder.Build();
            _cultureInfo = cultureInfo;
        }
Exemple #6
0
        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);
        }
Exemple #8
0
        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());
            });
        }
        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());
        }