Beispiel #1
0
        /// <summary>
        /// Read value from <see cref="MapField{TKey, TValue}"/>
        /// </summary>
        /// <param name="propertyBag"><see cref="MapField{TKey, TValue}"/> to read from</param>
        /// <returns>The <see cref="Dolittle.PropertyBags.PropertyBag"/></returns>
        public static Dolittle.PropertyBags.PropertyBag ToCLR(this MapField <string, System.Protobuf.Value> propertyBag)
        {
            var nullFreedictionary = new NullFreeDictionary <string, object>();

            propertyBag.ForEach(keyValue =>
            {
                var value = keyValue.Value.ToCLR();
                if (value != null)
                {
                    nullFreedictionary.Add(keyValue.Key, value);
                }
            });
            return(new Dolittle.PropertyBags.PropertyBag(nullFreedictionary));
        }
        /// <summary>
        /// Convert from <see cref="MapField{key,value}"/> to <see cref="PropertyBag"/>
        /// </summary>
        /// <param name="mapField"><see cref="MapField{key,value}"/> to convert from</param>
        /// <returns>Converted <see cref="PropertyBag"/></returns>
        public static PropertyBag ToPropertyBag(this MapField <string, System.Protobuf.Object> mapField)
        {
            var dictionary = new NullFreeDictionary <string, object>();

            mapField.ForEach(keyValue =>
            {
                var value = keyValue.Value.ToCLR();
                if (value != null)
                {
                    dictionary.Add(keyValue.Key, value);
                }
            });
            return(new PropertyBag(dictionary));
        }