private void ParseString() { try { Match match; int startat = 0; this.lineNumber = 1; if (this.serviceText.IndexOf('>') == -1) { throw FxTrace.Exception.AsError(new HttpException(System.ServiceModel.Activation.SR.Hosting_BuildProviderDirectiveEndBracketMissing("ServiceHost"))); } Label_0033: match = directiveRegex.Match(this.serviceText, startat); if (match.Success) { this.lineNumber += ServiceParserUtilities.LineCount(this.serviceText, startat, match.Index); startat = match.Index; IDictionary attribs = CollectionsUtil.CreateCaseInsensitiveSortedList(); string directiveName = this.ProcessAttributes(match, attribs); this.ProcessDirective(directiveName, attribs); this.lineNumber += ServiceParserUtilities.LineCount(this.serviceText, startat, match.Index + match.Length); startat = match.Index + match.Length; int num2 = this.serviceText.LastIndexOfAny(newlineChars, startat - 1); this.startColumn = startat - num2; goto Label_0033; } if (!this.foundMainDirective) { throw FxTrace.Exception.AsError(new HttpException(System.ServiceModel.Activation.SR.Hosting_BuildProviderDirectiveMissing("ServiceHost"))); } string s = this.serviceText.Substring(startat); if (!ServiceParserUtilities.IsWhiteSpaceString(s)) { this.sourceString = s; } } catch (HttpException exception) { Exception innerException = this.CreateParseException(exception, this.serviceText); throw FxTrace.Exception.AsError(new HttpCompileException(innerException.Message, innerException)); } }
/// <summary> /// Parses the content of the svc file for each directive line /// </summary> void ParseString() { try { int textPos = 0; Match match; lineNumber = 1; // Check for ending bracket first, MB 45013. if (this.serviceText.IndexOf('>') == -1) { throw FxTrace.Exception.AsError(new HttpException(SR.Hosting_BuildProviderDirectiveEndBracketMissing(ServiceParser.DefaultDirectiveName))); } // First, parse all the <%@ ... %> directives // for (;;) { match = directiveRegex.Match(this.serviceText, textPos); // Done with the directives? // if (!match.Success) { break; } lineNumber += ServiceParserUtilities.LineCount(this.serviceText, textPos, match.Index); textPos = match.Index; // Get all the directives into a bag // IDictionary directive = CollectionsUtil.CreateCaseInsensitiveSortedList(); string directiveName = ProcessAttributes(match, directive); // Understand the directive // ProcessDirective(directiveName, directive); lineNumber += ServiceParserUtilities.LineCount(this.serviceText, textPos, match.Index + match.Length); textPos = match.Index + match.Length; // Fixup line and column numbers to have meaninglful errors // int newlineIndex = this.serviceText.LastIndexOfAny(newlineChars, textPos - 1); startColumn = textPos - newlineIndex; } if (!foundMainDirective) { throw FxTrace.Exception.AsError(new HttpException(SR.Hosting_BuildProviderDirectiveMissing(ServiceParser.DefaultDirectiveName))); } // skip the directives chunk // string remainingText = this.serviceText.Substring(textPos); // If there is something else in the file, it needs to be compiled // if (!ServiceParserUtilities.IsWhiteSpaceString(remainingText)) { sourceString = remainingText; } } catch (HttpException e) { // the string is set in the internal exception, no need to set it again. // Exception parseException = CreateParseException(e, this.serviceText); throw FxTrace.Exception.AsError( new HttpCompileException(parseException.Message, parseException)); } }