Example #1
0
        /// <summary>
        /// Gets a <see cref="ChannelDataReader"/> for a <see cref="Witsml200.ChannelSet"/> instance.
        /// </summary>
        /// <param name="channelSet">The channel set.</param>
        /// <returns>A <see cref="ChannelDataReader"/> </returns>
        public static ChannelDataReader GetReader(this Witsml200.ChannelSet channelSet)
        {
            var data = Witsml200.Extensions.GetData(channelSet);

            if (string.IsNullOrWhiteSpace(data))
            {
                return(null);
            }

            _log.DebugFormat("Creating ChannelDataReader for {0}", channelSet.GetType().FullName);

            // Not including index channels with value channels
            var mnemonics  = channelSet.Channel.Select(x => x.Mnemonic).ToArray();
            var units      = channelSet.Channel.Select(x => x.Uom.ToString()).ToArray();
            var dataTypes  = channelSet.Channel.Select(x => x.DataType?.ToString()).ToArray();
            var nullValues = new string[units.Length];

            return(new ChannelDataReader(data, mnemonics, units, dataTypes, nullValues, channelSet.GetUri())
                   // Add index channels to separate collection
                   .WithIndices(channelSet.Index.Select(ToChannelIndexInfo), true));
        }