public void GetStringValue_EmptyStringToEmptyArray_ReturnEmptyArray()
        {
            //Act
            var actual = TypeUtilEx.TryParseString(string.Empty, typeof(string[]), out var result, CultureInfo.InvariantCulture, StringSplitOptions.RemoveEmptyEntries);

            //Assert
            actual.ShouldBeTrue();
            var output = result.ShouldBeOfType <string[]>();

            output.ShouldBeEmpty();
        }
Esempio n. 2
0
        public static T GetMessageContent <T>(this IRequestContext context) where T : Document
        {
            var content   = context.GetVariable <string>(CONTENT_VARIABLE_NAME);
            var mediaType = context.GetVariable <MediaType>(TYPE_VARIABLE_NAME);

            if (mediaType.IsJson)
            {
                return(JsonConvert.DeserializeObject <T>(content, JsonNetSerializer.Settings));
            }
            else
            {
                object document;
                if (TypeUtilEx.TryParseString(content, typeof(T), out document))
                {
                    return((T)document);
                }
                return(null);
            }
        }