Exemplo n.º 1
0
        /// <summary>
        /// Returns information about the first reference found, starting from the 0-based
        /// startIndex position in the line. Null is returned if the line has no reference.
        /// </summary>
        ReferenceInfo GetFirstReference(string line, int startIndex)
        {
            ReferenceInfo result = null;

            if (startIndex <= line.Length)
            {
                int openingRefPos = line.IndexOf(cReferenceSignature_Start, startIndex);
                if (openingRefPos >= 0)
                {
                    // check the reference isn't escaped
                    if (openingRefPos == 0 || line[openingRefPos - 1] != '\\')   // Need to fix this: Any escape slashes should be removed, and a double-slash should allow a slash to appear before an expansion
                    // check the reference has a closing "}"
                    {
                        int closingRefPos = line.IndexOf(cReferenceSignature_End, openingRefPos + cReferenceSignature_Start.Length);

                        if (closingRefPos > openingRefPos)
                        {
                            result = new ReferenceInfo(
                                openingRefPos,                                                                                                                       // Start of the reference
                                (closingRefPos - openingRefPos) + cReferenceSignature_End.Length,                                                                    // characters occupied by the reference
                                line.Substring(openingRefPos + cReferenceSignature_Start.Length, closingRefPos - (openingRefPos + cReferenceSignature_Start.Length)) // referred msgid
                                );
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns information about the first reference found, starting from the 0-based
        /// startIndex position in the line. Null is returned if the line has no reference.
        /// </summary>
        ReferenceInfo GetFirstReference(string line, int startIndex)
        {
            ReferenceInfo result = null;

            if (startIndex <= line.Length) {

                int openingRefPos = line.IndexOf(cReferenceSignature_Start, startIndex);
                if (openingRefPos >= 0) {
                    // check the reference isn't escaped
                    if (openingRefPos == 0 || line[openingRefPos - 1] != '\\') { // Need to fix this: Any escape slashes should be removed, and a double-slash should allow a slash to appear before an expansion
                        // check the reference has a closing "}"
                        int closingRefPos = line.IndexOf(cReferenceSignature_End, openingRefPos + cReferenceSignature_Start.Length);

                        if (closingRefPos > openingRefPos) {
                            result = new ReferenceInfo(
                                openingRefPos, // Start of the reference
                                (closingRefPos - openingRefPos) + cReferenceSignature_End.Length, // characters occupied by the reference
                                line.Substring(openingRefPos + cReferenceSignature_Start.Length, closingRefPos - (openingRefPos + cReferenceSignature_Start.Length)) // referred msgid
                            );
                        }
                    }
                }
            }
            return result;
        }