Example #1
0
        public WordMorpheme(Morpheme morpheme, int order)
        {
            if (order < 0)
                throw new HangerdException("排序值不可小于0");

            Morpheme = morpheme;
            Order = order;
        }
Example #2
0
        public HangerdResult<MorphemeDto> AddMorpheme(MorphemeDto morphemeDto)
        {
            return TryOperate(() =>
            {
                using (var unitOfWork = DbContextFactory.CreateContext())
                {
                    var morphemeRepository = unitOfWork.GetRepository<IMorphemeRepository>();
                    var morpheme = new Morpheme(
                        morphemeDto.Standard,
                        morphemeDto.Variant,
                        morphemeDto.Description,
                        (MorphemeType) morphemeDto.Type);

                    morphemeRepository.Add(morpheme);

                    unitOfWork.Commit();

                    return Mapper.Map<Morpheme, MorphemeDto>(morpheme);
                }
            });
        }
Example #3
0
        public void AddMorpheme(Morpheme morpheme)
        {
            if (Morphemes == null)
                throw new HangerdException("Morphemes has not been loaded.");

            if (Morphemes.Any(m => m.Morpheme.Id == morpheme.Id))
                throw new HangerdException("该词素已添加");

            Morphemes.Add(new WordMorpheme(morpheme, Morphemes.Count));
        }