Example #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="KeyTermMatch"/> class.
        /// </summary>
        /// <param name="words">The words.</param>
        /// <param name="term">The term.</param>
        /// <param name="matchForRefOnly">if set to <c>true</c> [match for ref only].</param>
        /// ------------------------------------------------------------------------------------
        internal KeyTermMatch(IEnumerable <Word> words, IKeyTerm term, bool matchForRefOnly)
        {
            m_matchForRefOnly = matchForRefOnly;
            m_words           = words.ToList();
            m_terms           = new List <IKeyTerm>();
            m_terms.Add(term);
            KeyTermRenderingInfo info = m_keyTermRenderingInfo.FirstOrDefault(i => i.TermId == Term);

            if (info != null)
            {
                m_bestTranslation = info.PreferredRendering;
            }
        }
Example #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Determines whether the specified rendering can be deleted.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public bool CanRenderingBeDeleted(string rendering)
        {
            if (rendering == BestRendering)
            {
                return(false);
            }
            KeyTermRenderingInfo info = RenderingInfo;

            if (info == null)
            {
                return(false);
            }

            return(info.AddlRenderings.Contains(rendering.Normalize(NormalizationForm.FormC)));
        }
Example #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Determines whether the specified rendering can be deleted.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void DeleteRendering(string rendering)
        {
            rendering = rendering.Normalize(NormalizationForm.FormC);
            KeyTermRenderingInfo info = RenderingInfo;

            if (info == null || !info.AddlRenderings.Contains(rendering))
            {
                throw new ArgumentException("Cannot delete non-existent rendering: " + rendering);
            }

            if (info.AddlRenderings.Remove(rendering))
            {
                UpdateRenderingInfoFile();
            }
        }
Example #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds a rendering.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void AddRendering(string rendering)
        {
            if (Renderings.Contains(rendering.Normalize(NormalizationForm.FormD)))
            {
                throw new ArgumentException(Properties.Resources.kstidRenderingExists);
            }
            KeyTermRenderingInfo info = RenderingInfo;

            if (info == null)
            {
                info = new KeyTermRenderingInfo(Term, BestRendering);
                m_keyTermRenderingInfo.Add(info);
            }
            info.AddlRenderings.Add(rendering);
            UpdateRenderingInfoFile();
        }
Example #5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds a rendering.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void AddRendering(string rendering)
		{
			if (Renderings.Contains(rendering.Normalize(NormalizationForm.FormD)))
				throw new ArgumentException(Properties.Resources.kstidRenderingExists);
			KeyTermRenderingInfo info = RenderingInfo;
			if (info == null)
			{
				info = new KeyTermRenderingInfo(Term, BestRendering);
				m_keyTermRenderingInfo.Add(info);
			}
			info.AddlRenderings.Add(rendering);
			UpdateRenderingInfoFile();
		}