System.UriParser.GetComponents C# (CSharp) Method

GetComponents() protected method

protected GetComponents ( Uri uri, UriComponents components, UriFormat format ) : string
uri Uri
components UriComponents
format UriFormat
return string
        protected virtual string GetComponents(Uri uri, UriComponents components, UriFormat format)
        {
            if (((components & UriComponents.SerializationInfoString) != 0) && components != UriComponents.SerializationInfoString)
                throw new ArgumentOutOfRangeException(nameof(components), components, SR.net_uri_NotJustSerialization);

            if ((format & ~UriFormat.SafeUnescaped) != 0)
                throw new ArgumentOutOfRangeException(nameof(format));

            if (uri.UserDrivenParsing)
                throw new InvalidOperationException(SR.Format(SR.net_uri_UserDrivenParsing, this.GetType().ToString()));

            if (!uri.IsAbsoluteUri)
                throw new InvalidOperationException(SR.net_uri_NotAbsolute);

            return uri.GetComponentsHelper(components, format);
        }

Usage Example

Example #1
0
 string Lookup(ref string cache, UriComponents components, UriFormat format)
 {
     if (cache == null)
     {
         cache = parser.GetComponents(uri, components, format);
     }
     return(cache);
 }