// RZ: 5.6.2012 /// <summary> /// Loads the properties of the FreeMarker 'ftl' directive. /// </summary> private void loadTemplateProperties() { _StriptWhiteSpaces = false; try { if (RawText != string.Empty) { String startingTag = FTL_START_TAG; String endingTag = FTL_END_TAG; int startingPosition = 0; int endingPosition = 0; startingPosition = RawText.IndexOf(startingTag) + startingTag.Length; endingPosition = RawText.IndexOf(endingTag); String templateProperties = RawText.Substring(startingPosition, endingPosition - startingPosition); if (!String.IsNullOrEmpty(templateProperties)) { string[] pairs = templateProperties.Trim().Split(' '); foreach (String pair in pairs) { String[] value = pair.Split('='); value[0] = value[0].Trim(); if (value.Length == 2) { if (value[0].ToLower() == FTL_STRIP_WHITESPACE) { Boolean result = false; Boolean.TryParse(removeQuotes(value[1].Trim()), out result); _StriptWhiteSpaces = result; } } } } } } catch (Exception e) { } }
private void loadTemplateText() { try { if (RawText != string.Empty) { TemplateText = RawText.Substring(RawText.IndexOf("-->") + 3); } } catch (Exception e) { throw new Exception("Didn't find the end of the xml block.", e); } }
private void loadFormConfig() { try { if (RawText != string.Empty) { String startingTag = "<#--"; String endingTag = "-->"; int startingPosition = 0; int endingPosition = 0; startingPosition = RawText.IndexOf(startingTag) + startingTag.Length; endingPosition = RawText.IndexOf(endingTag); FormConfigXML = RawText.Substring(startingPosition, endingPosition - startingPosition); } } catch (Exception e) { throw new Exception("Didn't find any XML in the first comment.", e); } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public TravPathItem(int pStepIndex, string pRawText) { StepIndex = pStepIndex; RawText = pRawText.Trim(); Command = RawText + ""; vParams = new string[0]; int pi = RawText.IndexOf('('); if (pi != -1) { Command = Command.Substring(0, pi); BuildParams(pi); } Command = Command.Trim().ToLower(); if (Command.Length == 0) { throw NewStepFault(FabFault.Code.InvalidStep, "Step is empty."); } }
// Group: Private Functions // __________________________________________________________________________ /* Function: DetermineElement * Determines which <XMLElementType> the iterator is currently on, setting <type> and <length>. */ private void DetermineElement() { bool found = false; if (tokenIterator == null || !IsInBounds) { type = XMLElementType.OutOfBounds; length = 0; found = true; } // If we're on a new line and either whitespace or a comment token... else if ((RawTextIndex == 0 || Tokenizer.FundamentalTypeOf(RawText[RawTextIndex - 1]) == FundamentalType.LineBreak) && (tokenIterator.FundamentalType == FundamentalType.Whitespace || tokenIterator.CommentParsingType == CommentParsingType.CommentSymbol || tokenIterator.CommentParsingType == CommentParsingType.CommentDecoration)) { type = XMLElementType.Indent; length = 0; TokenIterator lookahead = tokenIterator; do { length += lookahead.RawTextLength; lookahead.Next(); }while (lookahead.RawTextIndex < endingRawTextIndex && (lookahead.FundamentalType == FundamentalType.Whitespace || lookahead.CommentParsingType == CommentParsingType.CommentSymbol || lookahead.CommentParsingType == CommentParsingType.CommentDecoration)); found = true; } else if (tokenIterator.FundamentalType == FundamentalType.LineBreak) { type = XMLElementType.LineBreak; length = tokenIterator.RawTextLength; found = true; } else if (tokenIterator.Character == '<') { int nextBracketIndex = RawText.IndexOfAny(AngleBrackets, RawTextIndex + 1); if (nextBracketIndex != -1 && nextBracketIndex < endingRawTextIndex && RawText[nextBracketIndex] == '>') { type = XMLElementType.Tag; length = nextBracketIndex + 1 - RawTextIndex; Match tagMatch = TagRegex.Match(RawText, RawTextIndex, length); if (tagMatch.Success) { found = true; tagType = tagMatch.Groups[1].ToString().ToLower(); } } } else if (tokenIterator.Character == '&') { int semicolonIndex = RawText.IndexOf(';', RawTextIndex + 1); if (semicolonIndex != -1 && semicolonIndex < endingRawTextIndex && HTMLEntityChars.IsEntityChar(RawText, RawTextIndex, semicolonIndex + 1 - RawTextIndex)) { type = XMLElementType.EntityChar; length = semicolonIndex + 1 - RawTextIndex; found = true; } } if (!found) { type = XMLElementType.Text; int nextElementIndex = RawText.IndexOfAny(StartOfElement, RawTextIndex + 1); if (nextElementIndex == -1) { length = endingRawTextIndex - RawTextIndex; } else { length = nextElementIndex - RawTextIndex; } } }
// Group: Private Functions // __________________________________________________________________________ /* Function: DetermineElement * Determines which <JavadocElementType> the iterator is currently on, setting <type> and <length>. */ private void DetermineElement() { bool found = false; if (tokenIterator == null || !IsInBounds) { type = JavadocElementType.OutOfBounds; length = 0; found = true; } // If we're on a new line and either whitespace or a comment token... else if ((RawTextIndex == 0 || Tokenizer.FundamentalTypeOf(RawText[RawTextIndex - 1]) == FundamentalType.LineBreak) && (tokenIterator.FundamentalType == FundamentalType.Whitespace || tokenIterator.CommentParsingType == CommentParsingType.CommentSymbol || tokenIterator.CommentParsingType == CommentParsingType.CommentDecoration)) { type = JavadocElementType.Indent; length = 0; TokenIterator lookahead = tokenIterator; do { length += lookahead.RawTextLength; lookahead.Next(); }while (lookahead.RawTextIndex < endingRawTextIndex && (lookahead.FundamentalType == FundamentalType.Whitespace || lookahead.CommentParsingType == CommentParsingType.CommentSymbol || lookahead.CommentParsingType == CommentParsingType.CommentDecoration)); found = true; } else if (tokenIterator.FundamentalType == FundamentalType.LineBreak) { type = JavadocElementType.LineBreak; length = tokenIterator.RawTextLength; found = true; } else if (tokenIterator.MatchesAcrossTokens("<!--")) { type = JavadocElementType.HTMLComment; int endingCommentIndex = RawText.IndexOf("-->", RawTextIndex + 4, endingRawTextIndex - (RawTextIndex + 4)); if (endingCommentIndex == -1) { length = endingRawTextIndex - RawTextIndex; } else { length = (endingCommentIndex + 3) - RawTextIndex; } found = true; } else if (tokenIterator.Character == '<') { int nextBracketIndex = RawText.IndexOfAny(AngleBrackets, RawTextIndex + 1); if (nextBracketIndex != -1 && nextBracketIndex < endingRawTextIndex && RawText[nextBracketIndex] == '>') { type = JavadocElementType.HTMLTag; length = nextBracketIndex + 1 - RawTextIndex; Match tagMatch = HTMLTagRegex.Match(RawText, RawTextIndex, length); if (tagMatch.Success) { found = true; tagType = tagMatch.Groups[1].ToString().ToLower(); } } } else if (tokenIterator.MatchesAcrossTokens("{@")) { int closingBrace = RawText.IndexOf('}', RawTextIndex + 2); TokenIterator lookahead = tokenIterator; lookahead.NextByCharacters(2); if (closingBrace != -1 && closingBrace < endingRawTextIndex && lookahead.FundamentalType == FundamentalType.Text && Parsers.Javadoc.InlineTags.Contains(lookahead.String)) { found = true; type = JavadocElementType.JavadocTag; tagType = lookahead.String; length = (closingBrace + 1) - RawTextIndex; } } else if (tokenIterator.Character == '@') { TokenIterator lookahead = tokenIterator; lookahead.Next(); if (lookahead.FundamentalType == FundamentalType.Text && Parsers.Javadoc.BlockTags.Contains(lookahead.String)) { found = true; type = JavadocElementType.JavadocTag; tagType = lookahead.String; length = tagType.Length + 1; } } else if (tokenIterator.Character == '&') { int semicolonIndex = RawText.IndexOf(';', RawTextIndex + 1); if (semicolonIndex != -1 && semicolonIndex < endingRawTextIndex && HTMLEntityChars.IsEntityChar(RawText, RawTextIndex, semicolonIndex + 1 - RawTextIndex)) { type = JavadocElementType.EntityChar; length = semicolonIndex + 1 - RawTextIndex; found = true; } } if (!found) { type = JavadocElementType.Text; int nextElementIndex = RawText.IndexOfAny(StartOfElement, RawTextIndex + 1); if (nextElementIndex == -1) { length = endingRawTextIndex - RawTextIndex; } else { length = nextElementIndex - RawTextIndex; } } }