Ejemplo n.º 1
0
        /// <summary>
        /// Read value from <see cref="System.Protobuf.ArrayValue"/>
        /// </summary>
        /// <param name="array"><see cref="System.Protobuf.ArrayValue"/> to read from</param>
        /// <returns>Array of values</returns>
        public static object[] ToCLR(this System.Protobuf.ArrayValue array)
        {
            var list = new List <object>();

            list.AddRange(array.Values.Select(val => val.ToCLR()));
            return(list.ToArray());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Converts a <see cref="System.Collections.IEnumerable"/> to <see cref="System.Protobuf.ArrayValue"/>
        /// </summary>
        /// <param name="enumerable"></param>
        /// <returns></returns>
        public static System.Protobuf.ArrayValue ToProtobuf(this System.Collections.IEnumerable enumerable)
        {
            var arrayValue = new System.Protobuf.ArrayValue();

            foreach (var item in enumerable)
            {
                arrayValue.Values.Add(item.ToProtobuf());
            }
            return(arrayValue);
        }