/// ------------------------------------------------------------------------------------ /// <summary> /// Finds the term rendering (from the known ones in the renderingInfo) in use in /// the current translation. /// </summary> /// <param name="renderingInfo">The information about a single occurrence of a key /// biblical term and its rendering in a string in the target language.</param> /// <returns>An object that indicates where in the translation string the match was /// found (offset and length)</returns> /// ------------------------------------------------------------------------------------ public SubstringDescriptor FindTermRenderingInUse(ITermRenderingInfo renderingInfo) { // This will almost always be 0, but if a term occurs more than once, this // will be the character offset following the occurrence of the rendering of // the preceding term in the translation. int ichStart = renderingInfo.EndOffsetOfRenderingOfPreviousOccurrenceOfThisTerm; int indexOfMatch = Int32.MaxValue; int lengthOfMatch = 0; foreach (string rendering in renderingInfo.Renderings) { int ich = Translation.IndexOf(rendering, ichStart, StringComparison.Ordinal); if (ich >= 0 && (ich < indexOfMatch || (ich == indexOfMatch && rendering.Length > lengthOfMatch))) { // Found an earlier or longer match. indexOfMatch = ich; lengthOfMatch = rendering.Length; } } if (lengthOfMatch == 0) { return(null); } return(new SubstringDescriptor(indexOfMatch, lengthOfMatch)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Finds the term rendering (from the known ones in the renderingInfo) in use in /// the current translation. /// </summary> /// <param name="renderingInfo">The information about a single occurrence of a key /// biblical term and its rendering in a string in the target language.</param> /// <param name="rowIndex">Index of the row.</param> /// <returns>An object that indicates where in the translation string the match was /// found (offset and length)</returns> /// ------------------------------------------------------------------------------------ private SubstringDescriptor FindTermRenderingInUse(ITermRenderingInfo renderingInfo, int rowIndex) { return m_helper[rowIndex].FindTermRenderingInUse(renderingInfo); }