SIL.CoreImpl.CpeTracker.CharPropEngine C# (CSharp) Method

CharPropEngine() public method

Get a suitable CPE for the specified character of the original string.
public CharPropEngine ( int ich ) : ILgCharacterPropertyEngine
ich int
return ILgCharacterPropertyEngine
		public ILgCharacterPropertyEngine CharPropEngine(int ich)
		{
			if (ich >= m_ichMinCpe && ich < m_ichLimCpe)
				return m_cpe;
			int ws;
			if (m_tssText == null)
			{
				ws = m_wsf.UserWs;
				// pick an arbitrary one, for any index.
				m_ichMinCpe = 0;
				m_ichLimCpe = int.MaxValue;
			}

			else
			{
				int irun = m_tssText.get_RunAt(ich);
				m_tssText.GetBoundsOfRun(irun, out m_ichMinCpe, out m_ichLimCpe);
				ws = m_tssText.get_WritingSystem(irun);
			}
			// different run, but may not differ in ws.
			if (ws != m_wsCpe)
			{
				m_wsCpe = ws;
				if (ws == -1)
				{
					// Bizarrely, the run has no WS specified. This happens occasionally in poorly-written tests.
					// Maybe there's some other way. Fall back to a default engine.
					m_cpe = LgIcuCharPropEngineClass.Create();
				}

				else
				{
					m_cpe = m_wsf.get_CharPropEngine(ws);
				}
			}
			return m_cpe;
		}
	}

Usage Example

Example #1
0
		/// <summary>
		///
		/// </summary>
		/// <param name="text"></param>
		/// <param name="wsf"></param>
		protected SegmentBreaker(ITsString text, ILgWritingSystemFactory wsf)
		{
			m_tssText = text;
			m_cpeTracker = new CpeTracker(wsf, text);
			// Make sure this is always something.
			m_cpe = m_cpeTracker.CharPropEngine(0);

			m_paraText = (m_tssText == null || m_tssText.Text == null) ? string.Empty : m_tssText.Text;
		}
All Usage Examples Of SIL.CoreImpl.CpeTracker::CharPropEngine