< Summary

Class:Microsoft.Azure.ServiceBus.Primitives.PropertyDictionary
Assembly:Microsoft.Azure.ServiceBus
File(s):C:\Git\azure-sdk-for-net\sdk\servicebus\Microsoft.Azure.ServiceBus\src\Primitives\PropertyDictionary.cs
Covered lines:0
Uncovered lines:35
Coverable lines:35
Total lines:119
Line coverage:0% (0 of 35)
Covered branches:0
Total branches:8
Branch coverage:0% (0 of 8)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-0%100%
.ctor(...)-0%100%
get_Keys()-0%100%
get_Values()-0%100%
get_Count()-0%100%
get_IsReadOnly()-0%100%
get_Item(...)-0%100%
set_Item(...)-0%0%
Add(...)-0%0%
ContainsKey(...)-0%100%
Remove(...)-0%100%
TryGetValue(...)-0%100%
Add(...)-0%100%
Clear()-0%100%
Contains(...)-0%100%
CopyTo(...)-0%100%
Remove(...)-0%100%
GetEnumerator()-0%100%
System.Collections.IEnumerable.GetEnumerator()-0%100%
IsSupportedObject(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\servicebus\Microsoft.Azure.ServiceBus\src\Primitives\PropertyDictionary.cs

#LineLine coverage
 1// Copyright (c) Microsoft. All rights reserved.
 2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
 3
 4namespace Microsoft.Azure.ServiceBus.Primitives
 5{
 6    using System;
 7    using System.Collections;
 8    using System.Collections.Generic;
 9    using Microsoft.Azure.ServiceBus.Amqp;
 10
 11    sealed class PropertyDictionary : IDictionary<string, object>
 12    {
 13        readonly IDictionary<string, object> inner;
 14
 015        public PropertyDictionary()
 16        {
 017            this.inner = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
 018        }
 19
 020        public PropertyDictionary(IDictionary<string, object> container)
 21        {
 022            this.inner = container;
 023        }
 24
 025        public ICollection<string> Keys => this.inner.Keys;
 26
 027        public ICollection<object> Values => this.inner.Values;
 28
 029        public int Count => this.inner.Count;
 30
 031        public bool IsReadOnly => this.inner.IsReadOnly;
 32
 33        public object this[string key]
 34        {
 035            get => this.inner[key];
 36
 37            set
 38            {
 039                if (this.IsSupportedObject(value))
 40                {
 041                    this.inner[key] = value;
 42                }
 043            }
 44        }
 45
 46        public void Add(string key, object value)
 47        {
 048            if (this.IsSupportedObject(value))
 49            {
 050                this.inner.Add(key, value);
 51            }
 052        }
 53
 54        public bool ContainsKey(string key)
 55        {
 056            return this.inner.ContainsKey(key);
 57        }
 58
 59        public bool Remove(string key)
 60        {
 061            return this.inner.Remove(key);
 62        }
 63
 64        public bool TryGetValue(string key, out object value)
 65        {
 066            return this.inner.TryGetValue(key, out value);
 67        }
 68
 69        public void Add(KeyValuePair<string, object> item)
 70        {
 071            this.inner.Add(item);
 072        }
 73
 74        public void Clear()
 75        {
 076            this.inner.Clear();
 077        }
 78
 79        public bool Contains(KeyValuePair<string, object> item)
 80        {
 081            return this.inner.Contains(item);
 82        }
 83
 84        public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
 85        {
 086            this.inner.CopyTo(array, arrayIndex);
 087        }
 88
 89        public bool Remove(KeyValuePair<string, object> item)
 90        {
 091            return this.inner.Remove(item);
 92        }
 93
 94        public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
 95        {
 096            return this.inner.GetEnumerator();
 97        }
 98
 99        IEnumerator IEnumerable.GetEnumerator()
 100        {
 0101            return this.inner.GetEnumerator();
 102        }
 103
 104        bool IsSupportedObject(object value)
 105        {
 0106            if (value != null)
 107            {
 0108                var type = value.GetType();
 109
 0110                if (!SerializationUtilities.IsSupportedPropertyType(type))
 111                {
 0112                    throw new ArgumentException(Resources.NotSupportedPropertyType.FormatForUser(type), nameof(value));
 113                }
 114            }
 115
 0116            return true;
 117        }
 118    }
 119}