Exemple #1
0
    public void TestBookmarkUri()
    {
        BookmarkUri uri = BookmarkUri.Parse("atlas://type/v3.1/id");

        Assert.AreEqual("atlas", uri.Prefix);
        Assert.AreEqual("type", uri.Type);
        Assert.AreEqual(new Version(3, 1), uri.Version);
        Assert.AreEqual("id", uri.Id);
    }
Exemple #2
0
    public static BookmarkUri Parse(string url)
    {
        Regex regex = new(@"(?<prefix>[a-zA-Z]+)\:\/\/(?<type>[-0-9a-zA-Z]+)\/v(?<version>[\d\.]+)\/(?<id>.+)");

        Match match = regex.Match(url);

        if (!match.Success)
        {
            return(null);
        }

        var uri = new BookmarkUri()
        {
            Url     = url,
            Prefix  = match.Groups["prefix"].Value.ToLower(),
            Type    = match.Groups["type"].Value.ToLower(),
            Version = ParseVersion(match.Groups["version"].Value),
            Id      = match.Groups["id"].Value,
        };

        return(uri);
    }