protected CultureRules(
            [NotNull] Func <PluralRules, PluralRules> plurals,
            [NotNull] Func <SingularRules, SingularRules> singulars,
            [NotNull] Func <IrregularRules, IrregularRules> irregulars,
            [NotNull] Func <UncountableRules, UncountableRules> uncountables,
            [NotNull] Func <int, string> ordanizeFunc)
        {
            if (plurals == null)
            {
                throw new ArgumentNullException(nameof(plurals));
            }
            if (singulars == null)
            {
                throw new ArgumentNullException(nameof(singulars));
            }
            if (uncountables == null)
            {
                throw new ArgumentNullException(nameof(uncountables));
            }
            if (ordanizeFunc == null)
            {
                throw new ArgumentNullException(nameof(ordanizeFunc));
            }
            RuleSet = new InflectorRuleSet(new List <InflectorRule>(), new List <InflectorRule>(), new List <string>(), ordanizeFunc);

            Plurals      = new PluralRules(RuleSet);
            Singulars    = new SingularRules(RuleSet);
            Uncountables = new UncountableRules(RuleSet);
            Irregulars   = new IrregularRules(Singulars, Plurals);

            plurals(Plurals);
            singulars(Singulars);
            uncountables(Uncountables);
            irregulars(Irregulars);
        }
Ejemplo n.º 2
0
        protected CultureRules(
            [NotNull] Func<PluralRules, PluralRules> plurals,
            [NotNull] Func<SingularRules, SingularRules> singulars,
            [NotNull] Func<IrregularRules, IrregularRules> irregulars,
            [NotNull] Func<UncountableRules, UncountableRules> uncountables,
            [NotNull] Func<int, string> ordanizeFunc)
        {
            if (plurals == null) throw new ArgumentNullException(nameof(plurals));
            if (singulars == null) throw new ArgumentNullException(nameof(singulars));
            if (uncountables == null) throw new ArgumentNullException(nameof(uncountables));
            if (ordanizeFunc == null) throw new ArgumentNullException(nameof(ordanizeFunc));
            RuleSet = new InflectorRuleSet(new List<InflectorRule>(), new List<InflectorRule>(), new List<string>(), ordanizeFunc);

            Plurals = new PluralRules(RuleSet);
            Singulars = new SingularRules(RuleSet);
            Uncountables = new UncountableRules(RuleSet);
            Irregulars = new IrregularRules(Singulars, Plurals);

            plurals(Plurals);
            singulars(Singulars);
            uncountables(Uncountables);
            irregulars(Irregulars);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds the singular.
 /// </summary>
 /// <param name="rule">The rule.</param>
 /// <param name="replacement">The replacement.</param>
 protected void AddSingular(string rule, string replacement)
 {
     SingularRules.Add(new Rule(rule, replacement));
 }