public bool IsAt(EscapedString str, int pos) { if (!Begin.IsMatch(str, pos)) { return(false); } return(End.Find(str, pos + Begin.Length) != null); }
public ParsingState(string source, LanguageSyntax languageSyntax) { this.languageSyntax = languageSyntax; String = new EscapedString(source, languageSyntax.EscapeChar); Position = 0; tagStack = new Stack <SyntaxNode>(); Root = SyntaxNode.CreateTag(LanguageSyntax.RootTagName); tagStack.Push(Root); }
/** * Get the repos for a given owner. */ public async Task <List <Repository> > ProcessRepositories(EscapedString owner) { var serializer = new DataContractJsonSerializer(typeof(List <Repository>)); var url = String.Format("https://api.github.com/orgs/{0}/repos", owner); var streamTask = client.GetStreamAsync(url); return(serializer.ReadObject(await streamTask) as List <Repository>); }
private bool IsMatch(EscapedString str, int pos, CharType template) { if (pos < 0 || pos >= str.Length) { return(true); } if (str[pos].IsEscaped) { return(false); } return(str[pos].Value.IsMatch(template)); }
/** * Get the repos for a given owner. */ public async Task <SearchResult> PerformSearch(EscapedString query) { var root = "https://api.github.com/search/repositories"; var parameter = "?q="; var serializer = new DataContractJsonSerializer(typeof(SearchResult)); var streamTask = client.GetStreamAsync(root + parameter + query); // Parse the JSON using a stream, to the model object return(serializer.ReadObject(await streamTask) as SearchResult); }
public int?Find(EscapedString str, int start) { for (int begin = start; begin >= 0; begin = str.ParsedString.IndexOf(Lexem, begin, StringComparison.InvariantCulture)) { if (IsMatch(str, begin)) { return(begin); } begin += 1; } return(null); }
public bool IsMatch(EscapedString str, int startPosition = 0) { if ((str.Length - startPosition) < Lexem.Length) { return(false); } if (!IsMatch(str, startPosition + Lexem.Length, nextCharTemplate)) { return(false); } if (!IsMatch(str, startPosition - 1, prevCharTemplate)) { return(false); } return(str.SubstringOrdinalEqual(Lexem, startPosition)); }
public void SeperatesWithSpecifiedSeperator() { IEnumerable <string> result = EscapedString.Seperate("first]second", ']'); CollectionAssert.AreEqual(new[] { "first", "second" }, result); }
public void CombinesWithSpecifiedSeperator() { string result = EscapedString.Combine(new[] { "first", "second" }, ';'); Assert.AreEqual("first;second", result); }
private void CombineTest(IEnumerable data, string expected) { string result = EscapedString.Combine(data); Assert.AreEqual(expected, result); }
private void SeperateTest(IEnumerable <string> expected, string data) { var result = EscapedString.Seperate(data); CollectionAssert.AreEqual(expected, result); }
private void SeperateTest(IEnumerable <string> expected, string data, bool trimWhitespaces = false) { var result = EscapedString.Seperate(data, trimWhitespaces); CollectionAssert.AreEqual(expected, result); }
public void NotOrdinalEqual_WhenSourceIs(string src, int compareStart, string other) { var parsed = new EscapedString(src, '\\'); parsed.SubstringOrdinalEqual(other, compareStart).Should().BeFalse(); }
public void CorrectlyParseEscapedLine_WhenString(string source, string expected) { var parsed = new EscapedString(source, '\\'); parsed.ToString().Should().Be(expected); }