IEnumerable<NewTile> filtered = newTiles // get me all new tiles...
.Where(
newTile => // ...for which it's true that...
oldTiles
.All( // ...for all the old tiles...
oldTile =>
!newTile.Navigation.OriginalString.EndsWith("?Scheme=" + oldTile.Scheme)));
// ...this condition is met.
Computational complexity of this is O(n2) I believe, so careful with handling large lists.
EDIT:
As for parsing the parameters (without HttpUtility), this can be done with an Uri and a Regex.
The trick is that since you only have a relative Uri
, you need to create an absolute one on the spot.
The following method worked for me:
string GetScheme(string relativeUri)
{
string fakeSite = "http://fake.com"; // as the following code wouldn't work on relative Uri!
Uri uri = new Uri(fakeSite + relativeUri);
string query = uri.Query;
string regexPattern = Regex.Escape("?Scheme=") + "(?<scheme>\\w+)";
Match match = new Regex(regexPattern).Match(query);
if (match.Captures.Count > 0)
{
return match.Groups["scheme"].Value;
}
return String.Empty;
}