public static Key CreateFromLocalReference(string reference) { string[] parts = reference.Split('/'); if (parts.Length == 2) { return(Key.Create(parts[0], parts[1], parts[3])); } else if (parts.Length == 4) { return(Key.Create(parts[0], parts[1], parts[3])); } else { throw new ArgumentException("Could not create key from local-reference: " + reference); } }
public static Key UriToKey(this ILocalhost localhost, Uri uri) { if (uri.IsAbsoluteUri && uri.IsTemporaryUri() == false) { return(localhost.IsBaseOf(uri) ? localhost.LocalUriToKey(uri) : throw new ArgumentException("Cannot create a key from a foreign Uri")); } if (uri.IsTemporaryUri()) { return(Key.Create(null, uri.ToString())); } var path = uri.ToString(); return(Key.ParseOperationPath(path)); }