예제 #1
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Matches the old check refs to the new check refs and copies over any renderings,
 /// then adds the ids of the old ChkTerms and ChkRefs to the set of IDs to be deleted.
 /// </summary>
 /// <param name="newKeyTerms">The CmPossibility whose SubPossiblities are the new key
 /// terms.</param>
 /// <param name="oldTerms">The old (top-level) key terms.</param>
 /// <param name="dlg">Progress dialog box (can be null)</param>
 /// ------------------------------------------------------------------------------------
 private void CopyRenderingsFromOldCheckRefs(ICmPossibility newKeyTerms,
                                             IFdoOwningSequence <ICmPossibility> oldTerms, IProgress dlg)
 {
     foreach (ICmPossibility poss in oldTerms)
     {
         // TE-7697, oldTerms contained something that wasn't a IChkTerm, so changed
         // using IChkTerm as loop variable to explicit cast and check for failure
         IChkTerm term = poss as IChkTerm;
         if (term != null)
         {
             foreach (IChkRef oldChkRef in term.OccurrencesOS)
             {
                 if (oldChkRef.Status != KeyTermRenderingStatus.Unassigned)
                 {
                     foreach (IChkRef newChkRef in ChkRefMatcher.FindCorrespondingChkRefs(
                                  newKeyTerms, oldChkRef))
                     {
                         newChkRef.Status      = oldChkRef.Status;
                         newChkRef.RenderingRA = oldChkRef.RenderingRA;
                         if (newChkRef.RenderingRA != null)
                         {
                             IChkTerm owningTerm = (IChkTerm)newChkRef.Owner;
                             bool     fRenderingAlreadyInCollection = false;
                             foreach (IChkRendering rendering in owningTerm.RenderingsOC)
                             {
                                 if (rendering.SurfaceFormRA == newChkRef.RenderingRA)
                                 {
                                     fRenderingAlreadyInCollection = true;
                                     break;
                                 }
                             }
                             if (!fRenderingAlreadyInCollection)
                             {
                                 IChkRendering rendering = m_servLoc.GetInstance <IChkRenderingFactory>().Create();
                                 owningTerm.RenderingsOC.Add(rendering);
                                 rendering.SurfaceFormRA = newChkRef.RenderingRA;
                             }
                         }
                     }
                 }
             }
             if (dlg != null)
             {
                 dlg.Step(1);
             }
         }
         CopyRenderingsFromOldCheckRefs(newKeyTerms, poss.SubPossibilitiesOS, null);
     }
 }
예제 #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Assigns a rendering for this check reference.
        /// </summary>
        /// <param name="wordForm">The word form.</param>
        /// ------------------------------------------------------------------------------------
        internal void AssignRendering(IWfiWordform wordForm)
        {
            if (wordForm == null)
            {
                throw new ArgumentNullException("wordForm", "Cannot assign a rendering to a null word form.");
            }
            RenderingStatus      = KeyTermRenderingStatus.Assigned;
            m_chkRef.RenderingRA = wordForm;

            IChkTerm owningChkTerm = (IChkTerm)m_chkRef.Owner;
            bool     fChkTermRenderingAlreadySet =
                owningChkTerm.RenderingsOC.Any(rendering => rendering.SurfaceFormRA == wordForm);

            if (!fChkTermRenderingAlreadySet)
            {
                IChkRendering newRendering = m_cache.ServiceLocator.GetInstance <IChkRenderingFactory>().Create();
                owningChkTerm.RenderingsOC.Add(newRendering);
                newRendering.SurfaceFormRA = wordForm;
            }
        }
예제 #3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="InvalidRendering"/> class.
		/// </summary>
		/// <param name="parentKeyTerm">The owner of the key term.</param>
		/// <param name="rendering">The invalid rendering.</param>
		/// ------------------------------------------------------------------------------------
		public InvalidRendering(IChkTerm parentKeyTerm, IChkRendering rendering)
		{
			m_parentKeyTerm = parentKeyTerm;
			m_rendering = rendering;
		}