System.Text.Normalization.GuessLength C# (CSharp) Method

GuessLength() private method

private GuessLength ( String strInput ) : int
strInput String
return int
        internal int GuessLength(String strInput)
        {
            if (strInput == null)
                throw new ArgumentNullException( "strInput",
                    Environment.GetResourceString("ArgumentNull_String"));

            // Get our guess
            int iError = 0;
            int iGuess = nativeNormalizationNormalizeString(
                normalizationForm, ref iError, strInput, strInput.Length, null, 0);

            // Could have an error (actually it'd be quite hard to have an error here)
            BCLDebug.Assert(iError == ERROR_SUCCESS, "GuessLength() shouldn't return errors.");
            if (iError != ERROR_SUCCESS)
            {
                // We shouldn't really be able to get here..., guessing length is
                // a trivial math function...
                // Can't really be Out of Memory, but just in case:
                if (iError == ERROR_NOT_ENOUGH_MEMORY)
                    throw new OutOfMemoryException(
                        Environment.GetResourceString("Arg_OutOfMemoryException"));

                // Who knows what happened?  Not us!
                throw new InvalidOperationException(
                    Environment.GetResourceString("UnknownError_Num", iError));
            }

            // Well, we guessed it
            return iGuess;
        }