public LinkExpressionEditor(LinkExpression expression) { this.expression = expression; InitializeComponent(); LoadData(); AddContextMenu(); }
public LinkExpression Link(Func <IUrlRegistry, string> urlsource) { var expression = new LinkExpression(urlsource); _links.Add(expression); return(expression); }
public void create_a_link() { var expression = new LinkExpression(x => x.UrlFor(new SomeLinkInput())) .Rel("some rel"); var urls = new StubUrlRegistry(); var link = expression.As <ILinkCreator>().CreateLink(urls); link.Url.ShouldBe(urls.UrlFor(new SomeLinkInput())); link.Rel.ShouldBe("some rel"); }
public void create_a_link() { var expression = new LinkExpression(x => x.UrlFor(new SomeLinkInput())) .Rel("some rel"); var urls = new StubUrlRegistry(); var link = expression.As<ILinkCreator>().CreateLink(urls); link.Url.ShouldEqual(urls.UrlFor(new SomeLinkInput())); link.Rel.ShouldEqual("some rel"); }
/// <summary> /// Parses the <paramref name="fileInfo" /> and adds parsed types to the /// <paramref name="extractorDatabase" /> /// </summary> /// <param name="fileInfo"></param> /// <param name="extractorDatabase"></param> public void Parse(IFileInfo fileInfo, IExtractorDatabase extractorDatabase) { Queue <Token> unProcessedTokens = _tokenizer.Tokenize(fileInfo); Token beginFileToken = unProcessedTokens.Dequeue(); // guard first token received is start of file token if (beginFileToken.TokenType != TokenType.BeginFile) { string msg = String.Format("received unexpected token type:{0} when token type should have been {1}", beginFileToken.TokenType, TokenType.BeginFile); throw new Exception(msg); } while (unProcessedTokens.Any()) { Token firstToken = unProcessedTokens.Dequeue(); // handle end of file if (firstToken.TokenType == TokenType.EndFile) { break; } // guard first token received is start of line token if (firstToken.TokenType != TokenType.BeginLine) { string msg = String.Format( "received unexpected token type:{0} when token type should have been {1}", firstToken.TokenType, TokenType.BeginLine); throw new Exception(msg); } TzDbLink?tzDbLink; if (LinkExpression.TryParse(unProcessedTokens, out tzDbLink)) { extractorDatabase.Links.Add(tzDbLink.Value); continue; } TzDbZoneDescription tzDbZoneDescription; if (ZoneDescriptionExpression.TryParse(unProcessedTokens, out tzDbZoneDescription)) { extractorDatabase.ZoneDescriptions.Add(tzDbZoneDescription); continue; } TzDbZoneDefinition tzDbZoneDefinition; if (ZoneDefinitionExpression.TryParse(unProcessedTokens, out tzDbZoneDefinition)) { extractorDatabase.ZoneDefinitions.Add(tzDbZoneDefinition); continue; } TzDbRule?tzDbRule; if (RuleExpression.TryParse(unProcessedTokens, out tzDbRule)) { extractorDatabase.Rules.Add(tzDbRule.Value); continue; } string unsupportedTokenMsg = String.Format("received unsupported tokens on line: {0} of file: {1}", firstToken.Value, fileInfo.Name); throw new Exception(unsupportedTokenMsg); } }