コード例 #1
0
        private static string GetResourceName(ExceptionResource resource)
        {
            Debug.Assert(Enum.IsDefined(typeof(ExceptionResource), resource),
                         "The enum value is not defined, please check the ExceptionResource Enum.");

            return(resource.ToString());
        }
コード例 #2
0
        //---------------------------------------------------------------------
        private static string GetResource(ExceptionResource ressource)
        {
            Debug.Assert(Enum.IsDefined(typeof(ExceptionResource), ressource),
                         $"The enum value is not defined, please check the {nameof(ExceptionResource)} enum.");

            return(s_resources.Value.GetString(ressource.ToString()));
        }
コード例 #3
0
 private static string GetResourceText(ExceptionResource resource)
 {
     return(resource.ToString());
 }
コード例 #4
0
        private static string GetResourceString(ref Utf8Json.Reader json, ExceptionResource resource, char character, string characters)
        {
            Debug.Assert(Enum.IsDefined(typeof(ExceptionResource), resource),
                         "The enum value is not defined, please check the ExceptionResource Enum.");

            string formatString = ExceptionStrings.ResourceManager.GetString(resource.ToString());
            string message      = formatString;

            switch (resource)
            {
            case ExceptionResource.ArrayDepthTooLarge:
                message = string.Format(formatString, json.CurrentDepth, json._utf8Json.MaxDepth);
                break;

            case ExceptionResource.ArrayEndWithinObject:
                if (json.CurrentDepth <= 0)
                {
                    formatString = ExceptionStrings.ResourceManager.GetString(ExceptionResource.DepthMustBePositive.ToString());
                    message      = string.Format(formatString, json.CurrentDepth);
                }
                else
                {
                    message = string.Format(formatString);
                }
                break;

            case ExceptionResource.EndOfStringNotFound:
                break;

            case ExceptionResource.ExpectedDigitNotFound:
                message = string.Format(formatString, character);
                break;

            case ExceptionResource.ExpectedDigitNotFoundEndOfData:
                message = string.Format(formatString, character);
                break;

            case ExceptionResource.ExpectedEndAfterSingleJson:
                message = string.Format(formatString, character);
                break;

            case ExceptionResource.ExpectedEndOfDigitNotFound:
                message = string.Format(formatString, character);
                break;

            case ExceptionResource.ExpectedNextDigitComponentNotFound:
                message = string.Format(formatString, character);
                break;

            case ExceptionResource.ExpectedNextDigitEValueNotFound:
                message = string.Format(formatString, character);
                break;

            case ExceptionResource.ExpectedSeparaterAfterPropertyNameNotFound:
                message = string.Format(formatString, character);
                break;

            case ExceptionResource.ExpectedStartOfPropertyNotFound:
                message = string.Format(formatString, character);
                break;

            case ExceptionResource.ExpectedStartOfPropertyOrValueNotFound:
                break;

            case ExceptionResource.ExpectedStartOfValueNotFound:
                message = string.Format(formatString, character);
                break;

            case ExceptionResource.ExpectedValueAfterPropertyNameNotFound:
                break;

            case ExceptionResource.FoundInvalidCharacter:
                message = string.Format(formatString, character);
                break;

            case ExceptionResource.InvalidEndOfJson:
                message = string.Format(formatString, json.TokenType);
                break;

            case ExceptionResource.ObjectDepthTooLarge:
                message = string.Format(formatString, json.CurrentDepth, json._utf8Json.MaxDepth);
                break;

            case ExceptionResource.ObjectEndWithinArray:
                if (json.CurrentDepth <= 0)
                {
                    formatString = ExceptionStrings.ResourceManager.GetString(ExceptionResource.DepthMustBePositive.ToString());
                    message      = string.Format(formatString, json.CurrentDepth);
                }
                else
                {
                    message = string.Format(formatString);
                }
                break;

            case ExceptionResource.Default:
                break;

            case ExceptionResource.ExpectedFalse:
                message = string.Format(formatString, characters);
                break;

            case ExceptionResource.ExpectedNull:
                message = string.Format(formatString, characters);
                break;

            case ExceptionResource.ExpectedTrue:
                message = string.Format(formatString, characters);
                break;

            // This case is covered between ArrayEndWithinObject and ObjectEndWithinArray

            /*case ExceptionResource.DepthMustBePositive:
             *  break;*/
            case ExceptionResource.InvalidCharacterWithinString:
                message = string.Format(formatString, character);
                break;

            case ExceptionResource.EndOfCommentNotFound:
                break;
            }

            return(message);
        }
コード例 #5
0
        private static string GetResourceString(ExceptionResource resource)
        {
            switch (resource)
            {
            case ExceptionResource.ArgumentOutOfRange_Index:
                return("Argument 'index' was out of the range of valid values.");

            case ExceptionResource.ArgumentOutOfRange_Count:
                return("Argument 'count' was out of the range of valid values.");

            case ExceptionResource.Arg_ArrayPlusOffTooSmall:
                return("Array plus offset too small.");

            case ExceptionResource.NotSupported_ReadOnlyCollection:
                return("This operation is not supported on a read-only collection.");

            case ExceptionResource.Arg_RankMultiDimNotSupported:
                return("Multi-dimensional arrays are not supported.");

            case ExceptionResource.Arg_NonZeroLowerBound:
                return("Arrays with a non-zero lower bound are not supported.");

            case ExceptionResource.ArgumentOutOfRange_ListInsert:
                return("Insertion index was out of the range of valid values.");

            case ExceptionResource.ArgumentOutOfRange_NeedNonNegNum:
                return("The number must be non-negative.");

            case ExceptionResource.ArgumentOutOfRange_SmallCapacity:
                return("The capacity cannot be set below the current Count.");

            case ExceptionResource.Argument_InvalidOffLen:
                return("Invalid offset length.");

            case ExceptionResource.ArgumentOutOfRange_BiggerThanCollection:
                return("The given value was larger than the size of the collection.");

            case ExceptionResource.Serialization_MissingKeys:
                return("Serialization error: missing keys.");

            case ExceptionResource.Serialization_NullKey:
                return("Serialization error: null key.");

            case ExceptionResource.NotSupported_KeyCollectionSet:
                return("The KeyCollection does not support modification.");

            case ExceptionResource.NotSupported_ValueCollectionSet:
                return("The ValueCollection does not support modification.");

            case ExceptionResource.InvalidOperation_NullArray:
                return("Null arrays are not supported.");

            case ExceptionResource.InvalidOperation_HSCapacityOverflow:
                return("Set hash capacity overflow. Cannot increase size.");

            case ExceptionResource.NotSupported_StringComparison:
                return("String comparison not supported.");

            case ExceptionResource.ConcurrentCollection_SyncRoot_NotSupported:
                return("SyncRoot not supported.");

            case ExceptionResource.ArgumentException_OtherNotArrayOfCorrectLength:
                return("The other array is not of the correct length.");

            case ExceptionResource.ArgumentOutOfRange_EndIndexStartIndex:
                return("The end index does not come after the start index.");

            case ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported:
                return("Huge arrays are not supported.");

            case ExceptionResource.Argument_AddingDuplicate:
                return("Duplicate item added.");

            case ExceptionResource.Argument_InvalidArgumentForComparison:
                return("Invalid argument for comparison.");

            case ExceptionResource.Arg_LowerBoundsMustMatch:
                return("Array lower bounds must match.");

            case ExceptionResource.Arg_MustBeType:
                return("Argument must be of type: ");

            case ExceptionResource.InvalidOperation_IComparerFailed:
                return("IComparer failed.");

            case ExceptionResource.NotSupported_FixedSizeCollection:
                return("This operation is not suppored on a fixed-size collection.");

            case ExceptionResource.Rank_MultiDimNotSupported:
                return("Multi-dimensional arrays are not supported.");

            case ExceptionResource.Arg_TypeNotSupported:
                return("Type not supported.");

            default:
                Debug.Assert(false,
                             "The enum value is not defined, please check the ExceptionResource Enum.");
                return(resource.ToString());
            }
        }