public DirectiveContext directive() { DirectiveContext _localctx = new DirectiveContext(Context, State); EnterRule(_localctx, 8, RULE_directive); int _la; try { EnterOuterAlt(_localctx, 1); { State = 46; Match(DIRECTIVE); State = 48; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << REGISTERREFERENCE) | (1L << REGISTER) | (1L << NAME) | (1L << NUMBER))) != 0)) { { State = 47; expressionList(); } } } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public void OnPageDirective(DirectiveContext context) { Assert.AreEqual(0, index); Assert.AreEqual(4, context.Attributes.Count); Assert.AreEqual("Page", context.DirectiveName); List <AttributeInfo> validAttrs = new List <AttributeInfo>(); validAttrs.Add(new AttributeInfo() { Name = "Language", Value = "C#", ContainsAspTags = false }); validAttrs.Add(new AttributeInfo() { Name = "AutoEventWireup", Value = "true", ContainsAspTags = false }); validAttrs.Add(new AttributeInfo() { Name = "CodeFile", Value = "EditPeople.aspx.cs", ContainsAspTags = false }); validAttrs.Add(new AttributeInfo() { Name = "Inherits", Value = "EditPeople", ContainsAspTags = false }); CheckAttrs(validAttrs, context.Attributes); index++; }
private void BuildDirectiveContexts() { var allDirs = _requestContext.ParsedRequest.AllDirectives; if (allDirs.Count == 0) { return; } foreach (var dir in allDirs) { var argValues = dir.GetArgValues(_requestContext); var dirContext = new DirectiveContext() { Directive = dir, ArgValues = argValues, RequestContext = _requestContext }; _requestContext.DirectiveContexts.Add(dirContext); } }
public DirectiveContext directive() { DirectiveContext _localctx = new DirectiveContext(_ctx, State); EnterRule(_localctx, 14, RULE_directive); try { EnterOuterAlt(_localctx, 1); { State = 67; label(); State = 68; Match(DIRECTIVE); State = 69; directive_args(); State = 70; Match(ENDL); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.ReportError(this, re); _errHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public void ProcessText() { // Arrange string buddyText = GetBuddyTextForTest(); // Act BuddyTextProcessor buddyTextProcessor = new BuddyTextProcessor(); TestcaseContext testcaseContext = buddyTextProcessor.ProcessText(buddyText); // Assert Assert.IsNotNull(testcaseContext, "testcaseContext != null"); ApplicationContext appCtx = testcaseContext.Application; Assert.IsNotNull(appCtx, "appCtx != null"); Assert.AreEqual("Verwaltung", appCtx.Name, "appCtx.Name != Verwaltung"); Version appVrsn = appCtx.Version; Assert.IsNotNull(appVrsn, "appVrsn != null"); Assert.AreEqual("9.512", appVrsn.Min, "appVrsn.Min != 9.512"); Assert.AreEqual("*", appVrsn.Max, "appVrsn.Max != *"); UsecaseContext usecaseCtx = testcaseContext.Usecase; Assert.IsNotNull(usecaseCtx, "usecaseCtx != null"); Assert.AreEqual("Mitarbeitermodul von GTÜ", usecaseCtx.Name, "usecaseCtx.Name has unexpected value"); ScenarioContext sceneCtx = testcaseContext.Scenario; Assert.IsNotNull(sceneCtx, "sceneCtx != null"); Assert.AreEqual("1. Grundtest ", sceneCtx.Name, "sceneCtx.Name has unexpected value"); ScenarioParameter[] sceneArgs = sceneCtx.ScenarioParameters; Assert.IsNotNull(sceneArgs, "sceneArgs != null"); Assert.AreEqual(3, sceneArgs.Length, "sceneArgs.Length != 3"); Assert.AreEqual("piNr", sceneArgs[0].Name, "sceneArgs[0].Name != piNr"); Assert.AreEqual("\"001\"", sceneArgs[0].Value, "sceneArgs[0].Value != \"001\""); Assert.AreEqual("piPass", sceneArgs[1].Name, "sceneArgs[1].Name != piPass"); Assert.AreEqual("\"Passw001\"", sceneArgs[1].Value, "sceneArgs[1].Value != \"Passw001\""); Assert.AreEqual("tabelle", sceneArgs[2].Name, "sceneArgs[2].Name != tabelle"); Assert.AreEqual("\"C:\\daten\\lfz.xls\"", sceneArgs[2].Value, "sceneArgs[2].Value != \"C:\\daten\\lfz.xls\""); Import[] importSet = testcaseContext.Imports; Assert.IsNotNull(importSet, "importSet != null"); Assert.AreEqual(2, importSet.Length, "importSet.Length != 2"); Assert.AreEqual("Verwaltung.s.Mitarbeitermodul.Meine_Daten_bearbeiten", importSet[0].Name, "importSet[0].Name has unexpected value"); Assert.AreEqual("Verwaltung.s.Mitarbeitermodul.Rechte_wiederherstellen", importSet[1].Name, "importSet[1].Name has unexpected value"); StepsContext stepsContext = testcaseContext.Steps; Assert.IsNotNull(stepsContext, "stepsContext != null"); DirectiveContext[] directiveSet = stepsContext.Directives; Assert.IsNotNull(directiveSet, "directiveSet != null"); Assert.AreEqual(8, directiveSet.Length, "directiveSet.Length != 8"); DirectiveContext frstDir = directiveSet[0]; Assert.AreEqual(5, frstDir.References.Length, "[1] directive: Unexpected reference count"); Assert.AreEqual("Wähle", frstDir.References[0].Value, "[1] directive: Unexpected verb"); Assert.IsAssignableFrom <ParameterReference>(frstDir.References[1], "[1] directive: Unexpected reference type"); Assert.AreEqual("piNr", frstDir.References[1].Value, "[1] directive: Unexpected reference value"); }
/// <summary> /// Called after page directive <%@ %> /// </summary> public void OnPageDirective(DirectiveContext context) { // add new imported namespace if (context.DirectiveName == "Import" && context.Attributes.Exists((info) => { return(info.Name == "Namespace"); })) { declaredNamespaces.Add(new UsedNamespaceItem(context.Attributes.Find((info) => { return(info.Name == "Namespace"); }).Value, null, true)); } if (context.DirectiveName == "Page" || context.DirectiveName == "Control") { string lang = null; // value of Language attribute string ext = null; // extension of the code-behind file foreach (var info in context.Attributes) { if (info.Name == "Language") { lang = info.Value; // get file language } if (info.Name == "CodeFile") // get code-behind file { int index = info.Value.LastIndexOf('.'); if (index != -1 && index + 1 < info.Value.Length) { ext = info.Value.Substring(index + 1); } } } if (string.IsNullOrEmpty(lang)) { if (!string.IsNullOrEmpty(ext)) // infer file language from the extension { fileLanguage = StringConstants.CsExtensions.Contains(ext.ToLower()) ? FILETYPE.CSHARP : FILETYPE.VB; } } else { fileLanguage = lang == "C#" ? FILETYPE.CSHARP : FILETYPE.VB; } } if (context.DirectiveName == "Register") { string assembly = null, nmspc = null, src = null, tagName = null, tagPrefix = null; foreach (AttributeInfo info in context.Attributes) { if (info.Name == "Assembly") { assembly = info.Value; } if (info.Name == "Namespace") { nmspc = info.Value; } if (info.Name == "Src") { src = info.Value; } if (info.Name == "TagName") { tagName = info.Value; } if (info.Name == "TagPrefix") { tagPrefix = info.Value; } } // add definitions of elements for future type resolution if (!string.IsNullOrEmpty(tagPrefix)) { if (!string.IsNullOrEmpty(assembly) && !string.IsNullOrEmpty(nmspc)) { if (webConfig != null) { webConfig.AddTagPrefixDefinition(new TagPrefixAssemblyDefinition(assembly, nmspc, tagPrefix)); } } else if (!string.IsNullOrEmpty(tagName) && !string.IsNullOrEmpty(src)) { if (webConfig != null) { webConfig.AddTagPrefixDefinition(new TagPrefixSourceDefinition(projectItem, VisualLocalizerPackage.Instance.DTE.Solution, tagName, src, tagPrefix)); } } } } if (parentCommand is BatchMoveCommand) // no resource references can be directly in the attributes, safe to look only for string literals { foreach (AttributeInfo info in context.Attributes) { if (info.ContainsAspTags) { continue; // attribute's value contains <%= - like tags - localization is not desirable } if (info.Name.ToLower() == "language") { continue; } AspNetStringResultItem item = AddResult(info, null, context.DirectiveName, context.WithinClientSideComment, false, false, true); if (item != null) { item.ComesFromDirective = true; item.AttributeName = info.Name; } } } }