protected virtual void AddDirective(Match match, string text) { ProcessLiteral(); CaptureCollection names = match.Groups["attrname"].Captures; CaptureCollection values = match.Groups["attrval"].Captures; Precondition.Require(names.Count > 0, () => Error.TemplateDirectiveCannotBeEmpty(_virtualPath, text, _lineNumber + 1)); string directiveName = names[0].Value; DirectiveExpression directive = new DirectiveExpression(directiveName); for (int i = 1; i < names.Count; ++i) { directive.Attributes.Add(names[i].Value, values[i].Value); } if (String.Equals(directiveName, ParsedTemplate.MainDirectiveName, StringComparison.InvariantCultureIgnoreCase)) { if (_hasMainDirective) { throw Error.DuplicateMainDirective(ParsedTemplate.MainDirectiveName, _virtualPath, text, _lineNumber + 1); } _hasMainDirective = true; _templateName = directive.Attributes["name"]; } Expressions.Add(directive); }
protected override void VisitDirective(DirectiveExpression directive) { base.VisitDirective(directive); switch (directive.Name.ToUpperInvariant()) { case "PARAMETER": // нам нужно выбрать параметры TemplateParameter parameter = new TemplateParameter( directive.Attributes["name"], Converter.ChangeType <int>(directive.Attributes["index"], 0), Type.GetType(directive.Attributes["type"] ?? String.Empty, false, true) ); _parameters.Add(parameter); break; } }
protected virtual void VisitDirective(DirectiveExpression directive) { }
protected override void VisitDirective(DirectiveExpression directive) { base.VisitDirective(directive); switch (directive.Name.ToUpperInvariant()) { case "PARAMETER": // нам нужно выбрать параметры TemplateParameter parameter = new TemplateParameter( directive.Attributes["name"], Converter.ChangeType<int>(directive.Attributes["index"], 0), Type.GetType(directive.Attributes["type"] ?? String.Empty, false, true) ); _parameters.Add(parameter); break; } }
protected virtual void AddDirective(Match match, string text) { ProcessLiteral(); CaptureCollection names = match.Groups["attrname"].Captures; CaptureCollection values = match.Groups["attrval"].Captures; Precondition.Require(names.Count > 0, () => Error.TemplateDirectiveCannotBeEmpty(_virtualPath, text, _lineNumber + 1)); string directiveName = names[0].Value; DirectiveExpression directive = new DirectiveExpression(directiveName); for (int i = 1; i < names.Count; ++i) directive.Attributes.Add(names[i].Value, values[i].Value); if (String.Equals(directiveName, ParsedTemplate.MainDirectiveName, StringComparison.InvariantCultureIgnoreCase)) { if (_hasMainDirective) throw Error.DuplicateMainDirective(ParsedTemplate.MainDirectiveName, _virtualPath, text, _lineNumber + 1); _hasMainDirective = true; _templateName = directive.Attributes["name"]; } Expressions.Add(directive); }