System.Uri.ParseMinimal C# (CSharp) Method

ParseMinimal() private method

private ParseMinimal ( ) : UriFormatException
return UriFormatException
        internal UriFormatException ParseMinimal()
        {
            ParsingError result = PrivateParseMinimal();
            if (result == ParsingError.None)
                return null;

            // Means the we think the Uri is invalid, bu that can be later overridden by a user parser
            _flags |= Flags.ErrorOrParsingRecursion;

            return GetException(result);
        }

Usage Example

Ejemplo n.º 1
0
        //
        // Parses and validates a Uri object, is called at the Uri ctor time.
        //
        // This method returns a non null parsingError if Uri being created is invalid:
        //
        protected virtual void InitializeAndValidate(Uri uri, out UriFormatException?parsingError)
        {
            if (uri._syntax is null)
            {
                throw new InvalidOperationException(SR.net_uri_NotAbsolute);
            }

            if (!ReferenceEquals(uri._syntax, this))
            {
                throw new InvalidOperationException(SR.Format(SR.net_uri_UserDrivenParsing, uri._syntax.GetType()));
            }

            Debug.Assert(sizeof(Uri.Flags) == sizeof(ulong));

            // If ParseMinimal is called multiple times this Uri instance may be corrupted, throw an exception instead
            ulong previous = Interlocked.Or(ref Unsafe.As <Uri.Flags, ulong>(ref uri._flags), (ulong)Uri.Flags.CustomParser_ParseMinimalAlreadyCalled);

            if (((Uri.Flags)previous & Uri.Flags.CustomParser_ParseMinimalAlreadyCalled) != 0)
            {
                throw new InvalidOperationException(SR.net_uri_InitializeCalledAlreadyOrTooLate);
            }

            parsingError = uri.ParseMinimal();
        }
All Usage Examples Of System.Uri::ParseMinimal