예제 #1
0
        public void RemoveInterpretation(string interpretationId)
        {
            if (Interpretations == null)
            {
                throw new HangerdException("Interpretations has not been loaded.");
            }

            if (Interpretations.Count == 1)
            {
                throw new HangerdException("至少保留一条释义");
            }

            var removedInterpretation = Interpretations.FirstOrDefault(e => e.Id == interpretationId);

            if (removedInterpretation == null)
            {
                throw new HangerdException("释义信息不存在");
            }

            Interpretations.Remove(removedInterpretation);

            foreach (var interpretation in Interpretations.Where(e => e.Order > removedInterpretation.Order))
            {
                interpretation.ModifyOrder(interpretation.Order - 1);
            }
        }
예제 #2
0
        public void AddInterpretation(PartOfSpeech partOfSpeech, string interpretation)
        {
            if (Interpretations == null)
            {
                throw new HangerdException("Interpretations has not been loaded.");
            }

            Interpretations.Add(new WordInterpretation(partOfSpeech, interpretation, Interpretations.Count));
        }
예제 #3
0
 public Given_an_Default_ActionSpecification()
 {
     _spec = Specifications.Action(new List <Binding <int> >
     {
         Rules <int>
         .Predicate(x => x % 2 == 0)
         .Bind(_ => Interpretations.Static("NOT_EVEN"), (_, i) => { Assert.Equal("NOT_EVEN", i.AsText()); _failureInvoked = true; },
               _ => Interpretations.Static("EVEN"), (_, i) => { Assert.Equal("EVEN", i.AsText()); _successInvoked = true; }),
         Rules <int>
         .Predicate(x => x > 0)
         .Bind(_ => Interpretations.Static("NOT_POSITIVE"), (_, i) => { Assert.Equal("NOT_POSITIVE", i.AsText()); _failureInvoked = true; },
               _ => Interpretations.Static("POSITIVE"), (_, i) => { Assert.Equal("POSITIVE", i.AsText()); _successInvoked = true; }),
     });
 }