opensim/OpenSim/Framework/Util.cs
/// <summary>
/// Parses a foreign asset ID.
/// </summary>
/// <param name="id">A possibly-foreign asset ID: http://grid.example.com:8002/00000000-0000-0000-0000-000000000000 </param>
/// <param name="url">The URL: http://grid.example.com:8002</param>
/// <param name="assetID">The asset ID: 00000000-0000-0000-0000-000000000000. Returned even if 'id' isn't foreign.</param>
/// <returns>True: this is a foreign asset ID; False: it isn't</returns>
Parses a foreign asset ID.
Parses a foreign asset ID .
public static bool ParseForeignAssetID(string id, out string url, out string assetID)
        {
            url = String.Empty;
            assetID = String.Empty;
            UUID uuid;
            if (UUID.TryParse(id, out uuid))
            {
                assetID = uuid.ToString();
                return false;
            }
            if ((id.Length == 0) || (id[0] != 'h' && id[0] != 'H'))
                return false;
            Uri assetUri;
            if (!Uri.TryCreate(id, UriKind.Absolute, out assetUri) || assetUri.Scheme != Uri.UriSchemeHttp)
                return false;
            if (assetUri.Query != string.Empty)
            {
                NameValueCollection qscoll = HttpUtility.ParseQueryString(assetUri.Query);
                assetID = qscoll["id"];
                if (assetID != null)
                    url = id.Replace(assetID, ""); 
                else
                    url = id; 
            }
            else 
            {
                url = "http://" + assetUri.Authority;
                assetID = assetUri.LocalPath.Trim(new char[] { '/' });
            }
            if (!UUID.TryParse(assetID, out uuid))
                return false;
            return true;
        }
public static bool ParseForeignAssetID ( string id , out string url , out string assetID ) { url = String . Empty ; assetID = String . Empty ; UUID uuid ; if ( UUID . TryParse ( id , out uuid ) ) { assetID = uuid . ToString ( ) ; return false ; } if ( ( id . Length == 0 ) || ( id [ 0 ] != ' ' && id [ 0 ] != ' ' ) ) return false ; Uri assetUri ; if ( ! Uri . TryCreate ( id , UriKind . Absolute , out assetUri ) || assetUri . Scheme != Uri . UriSchemeHttp ) return false ; if ( assetUri . Query != string . Empty ) { NameValueCollection qscoll = HttpUtility . ParseQueryString ( assetUri . Query ) ; assetID = qscoll [ " " ] ; if ( assetID != null ) url = id . Replace ( assetID , " " ) ; else url = id ; } else { url = " " + assetUri . Authority ; assetID = assetUri . LocalPath . Trim ( new char [ ] { ' ' } ) ; } if ( ! UUID . TryParse ( assetID , out uuid ) ) return false ; return true ; }
Parses a foreign asset ID.
Parses a foreign asset ID .
// Simian // Malformed again, as simian expects // !!! best effort // robust
this is a foreign asset ID; False: it isn't
this is a foreign asset ID ; False : it isn ' t
id
string
None
string
out
url
None
assetID
None