< Summary

Class:Azure.Messaging.ServiceBus.Amqp.SerializationUtilities
Assembly:Azure.Messaging.ServiceBus
File(s):C:\Git\azure-sdk-for-net\sdk\servicebus\Azure.Messaging.ServiceBus\src\Amqp\SerializationUtilities.cs
Covered lines:27
Uncovered lines:2
Coverable lines:29
Total lines:67
Line coverage:93.1% (27 of 29)
Covered branches:2
Total branches:4
Branch coverage:50% (2 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.cctor()-100%100%
GetTypeId(...)-60%50%
IsSupportedPropertyType(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\servicebus\Azure.Messaging.ServiceBus\src\Amqp\SerializationUtilities.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Collections.Generic;
 6
 7namespace Azure.Messaging.ServiceBus.Amqp
 8{
 9    // WARNING: Consult filter engine owner before modifying this enum.
 10    // Introducing a new member here has impact to filtering engine in data type precedence and data conversion.
 11    // ALWAYS insert new types before Unknown!
 12    internal enum PropertyValueType
 13    {
 14        Null,
 15        Byte, SByte, Char, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double, Decimal, // Numeric types
 16        Boolean, Guid, String, Uri, DateTime, DateTimeOffset, TimeSpan,
 17        Stream,
 18        Unknown,
 19    }
 20
 21    internal class SerializationUtilities
 22    {
 223        private static readonly Dictionary<Type, PropertyValueType> s_typeToIntMap = new Dictionary<Type, PropertyValueT
 224        {
 225            { typeof(byte), PropertyValueType.Byte },
 226            { typeof(sbyte), PropertyValueType.SByte },
 227            { typeof(char), PropertyValueType.Char },
 228            { typeof(short), PropertyValueType.Int16 },
 229            { typeof(ushort), PropertyValueType.UInt16 },
 230            { typeof(int), PropertyValueType.Int32 },
 231            { typeof(uint), PropertyValueType.UInt32 },
 232            { typeof(long), PropertyValueType.Int64 },
 233            { typeof(ulong), PropertyValueType.UInt64 },
 234            { typeof(float), PropertyValueType.Single },
 235            { typeof(double), PropertyValueType.Double },
 236            { typeof(decimal), PropertyValueType.Decimal },
 237            { typeof(bool), PropertyValueType.Boolean },
 238            { typeof(Guid), PropertyValueType.Guid },
 239            { typeof(string), PropertyValueType.String },
 240            { typeof(Uri), PropertyValueType.Uri },
 241            { typeof(DateTime), PropertyValueType.DateTime },
 242            { typeof(DateTimeOffset), PropertyValueType.DateTimeOffset },
 243            { typeof(TimeSpan), PropertyValueType.TimeSpan },
 244            ////{ typeof(BufferedInputStream), PropertyValueType.Stream },
 245        };
 46
 47        public static PropertyValueType GetTypeId(object value)
 48        {
 449            if (value == null)
 50            {
 051                return PropertyValueType.Null;
 52            }
 53
 454            if (s_typeToIntMap.TryGetValue(value.GetType(), out var propertyValueType))
 55            {
 456                return propertyValueType;
 57            }
 58
 059            return PropertyValueType.Unknown;
 60        }
 61
 62        public static bool IsSupportedPropertyType(Type type)
 63        {
 17264            return s_typeToIntMap.ContainsKey(type);
 65        }
 66    }
 67}