Пример #1
0
        /// <summary>
        /// <para>将指定的键和值添加到Map</para>
        /// <para>Adds the specified key and value to the Map</para>
        /// </summary>
        public void Add(object key, object value)
        {
            if (key is BssomValue bsVal)
            {
                switch (bsVal.ValueType)
                {
                case BssomValueType.Number:
                case BssomValueType.String:
                case BssomValueType.Guid:
                case BssomValueType.Boolean:
                case BssomValueType.Char:
                case BssomValueType.DateTime:
                case BssomValueType.Decimal:
                case BssomValueType.Float:
                {
                    _dict.Add(key, value);
                    return;
                }

                default:
                    throw BssomSerializationTypeFormatterException.BssomMapKeyUnsupportedType(key.GetType());
                }
            }

            BssMapKeyResolverProvider.VertyBssMapKeyType(key);
            _dict.Add(key, value);
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BssomMap"/> class that contains elements copied from the specified IEnumerable
        /// </summary>
        /// <param name="ienums"></param>
        public BssomMap(IEnumerable <KeyValuePair <object, object> > ienums)
        {
            if (ienums.TryGetICollectionCount(out int count))
            {
                _dict = new Dictionary <object, object>(count);
            }
            else
            {
                _dict = new Dictionary <object, object>();
            }

            foreach (KeyValuePair <object, object> item in ienums)
            {
                BssMapKeyResolverProvider.VertyBssMapKeyType(item.Key);
                _dict.Add(item.Key, item.Value);
            }
        }