示例#1
0
        /// <summary> Create or replace entry with specified key </summary>
        /// <exception cref="ArgumentException"></exception>
        public static PutAppendResult Put(this PagedContainerAbstract c, string key, string data)
        {
            if (string.IsNullOrEmpty(data))
            {
                throw new ArgumentException("Argument can't be null or empty", nameof(data));
            }

            return(c.Put(key, defaultEncoding.GetBytes(data)));
        }
示例#2
0
        /// <summary>
        /// Create or replace of passed entries.
        /// Value in dictionary must not be null or empty.
        /// </summary>
        /// <exception cref="ArgumentException"></exception>

        public static Dictionary <string, PutAppendResult> Put(this PagedContainerAbstract c, Dictionary <string, string> keyValues)
        {
            foreach (var item in keyValues)
            {
                if (string.IsNullOrEmpty(item.Key))
                {
                    throw new ArgumentException("Argument can't be null or empty", nameof(keyValues));
                }

                if (string.IsNullOrEmpty(item.Value))
                {
                    throw new ArgumentException($"Argument can't be null or empty: {item.Key}", nameof(keyValues));
                }
            }

            return(c.Put(keyValues.ToDictionary(p => p.Key, p => defaultEncoding.GetBytes(p.Value), StringComparer.InvariantCultureIgnoreCase)));
        }