コード例 #1
0
        public PronounDictionary Move(Pronoun from, Pronoun to)
        {
            var result = new PronounDictionary(this);

            result[to] = this[from];
            return(result);
        }
コード例 #2
0
        public static PronounDictionary operator +(string prefix, PronounDictionary pd)
        {
            var pd1 = new PronounDictionary(prefix);
            var pd2 = pd;

            return(pd1 + pd2);
        }
コード例 #3
0
        public static PronounDictionary operator +(PronounDictionary pd, string postfix)
        {
            var pd1 = pd;
            var pd2 = new PronounDictionary(postfix);

            return(pd1 + pd2);
        }
コード例 #4
0
        public PronounDictionary Remove(List <Pronoun> pronouns)
        {
            var result = new PronounDictionary(this);

            foreach (var pronoun in ImperativePronouns())
            {
                result.Remove(pronoun);
            }
            return(result);
        }
コード例 #5
0
        public void SetTense(Mood mood, Tense tense, PronounDictionary pronounDictionary)
        {
            var key = new KeyValuePair <Mood, Tense>(mood, tense);

            if (this.ContainsKey(key))
            {
                this[key] = pronounDictionary;
            }
            else
            {
                this.Add(key, pronounDictionary);
            }
        }
コード例 #6
0
        public PronounDictionary ToImperative()
        {
            var imperativePronouns = ImperativePronouns();
            var result             = new PronounDictionary(this);

            foreach (var pronoun in this.Keys.ToList())
            {
                if (!imperativePronouns.Contains(pronoun))
                {
                    result.Remove(pronoun);
                }
            }
            return(result);
        }
コード例 #7
0
        public static ConjugationOptions GetRandomConjugationOption()
        {
            var conjugations = Verb.AllConjugations();
            var conjugation  = conjugations[r.Next(conjugations.Count)];
            var pronouns     = Enum.GetValues(typeof(Pronoun)).Cast <Pronoun>().ToList();
            var mood         = conjugation.Item1;
            var tense        = conjugation.Item2;

            if (mood == Mood.Imperative)
            {
                pronouns = PronounDictionary.ImperativePronouns();
            }
            var pronoun = (Pronoun)pronouns[r.Next(pronouns.Count)];

            return(new ConjugationOptions(mood, tense, pronoun));
        }
コード例 #8
0
        public static PronounDictionary operator +(PronounDictionary pd1, PronounDictionary pd2)
        {
            var result = new PronounDictionary();

            foreach (var kvp in pd1)
            {
                Pronoun p       = kvp.Key;
                string  prefix  = kvp.Value;
                string  postfix = null;
                if (pd2.TryGetValue(p, out postfix))
                {
                    result.Add(p, prefix.Merge(postfix));
                }
            }

            return(result);
        }
コード例 #9
0
 public PronounDictionary(PronounDictionary dictionary) : base(dictionary)
 {
 }