Exemple #1
0
        Uri InternalizeReference(Uri uri)
        {
            if (uri == null)
            {
                return(null);
            }

            // If it is a reference to another contained resource don not internalize.
            // BALLOT: this seems very... ad hoc.
            if (uri.HasFragment())
            {
                return(uri);
            }


            if (localhost.IsBaseOf(uri))
            {
                Key key = localhost.UriToKey(uri);
                return(InternalizeReference(key).ToUri());
            }
            else
            {
                return(uri);
            }
        }
Exemple #2
0
        string InternalizeReference(string uristring)
        {
            if (string.IsNullOrWhiteSpace(uristring))
            {
                return(uristring);
            }

            Uri uri = new Uri(uristring, UriKind.RelativeOrAbsolute);

            // If it is a reference to another contained resource do not internalize.
            // BALLOT: this seems very... ad hoc.
            if (uri.HasFragment())
            {
                return(uristring);
            }

            if (uri.IsTemporaryUri() || localhost.IsBaseOf(uri))
            {
                IKey key = localhost.UriToKey(uri);
                return(InternalizeReference(key).ToUri().ToString());
            }
            else
            {
                return(uristring);
            }
        }
Exemple #3
0
 public static bool IsLocal(this ILocalhost localhost, IKey key)
 {
     if (key.Base == null)
     {
         return(true);
     }
     return(localhost.IsBaseOf(key.Base));
 }
Exemple #4
0
        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));
        }
 public static Key UriToKey(this ILocalhost localhost, Uri uri)
 {
     if (uri.IsAbsoluteUri)
     {
         if (localhost.IsBaseOf(uri))
         {
             return(localhost.LocalUriToKey(uri));
         }
         else
         {
             return(ForeignUriToKey(uri));
         }
     }
     else
     {
         string path = uri.ToString();
         return(Key.ParseOperationPath(path));
     }
 }
 public static Key UriToKey(this ILocalhost localhost, Uri uri)
 {
     if (uri.IsAbsoluteUri)
     {
         if (localhost.IsBaseOf(uri))
         {
             return(localhost.LocalUriToKey(uri));
         }
         else
         {
             throw new ArgumentException("Cannot create a key from a foreign Uri");
         }
     }
     else
     {
         string path = uri.ToString();
         return(Key.ParseOperationPath(path));
     }
 }
Exemple #7
0
        public static bool IsBaseOf(this ILocalhost localhost, string uristring)
        {
            Uri uri = new Uri(uristring, UriKind.RelativeOrAbsolute);

            return(localhost.IsBaseOf(uri));
        }
Exemple #8
0
 public static bool IsLocal(this ILocalhost localhost, IKey key) =>
 key.Base == null || localhost.IsBaseOf(key.Base);