Ejemplo n.º 1
0
        /// <summary>
        /// Calls command and reads all returned rows for given <paramref name="durationSec"/> period.
        /// After this period calls cancell to mikrotik router and returns all loaded rows.
        /// Throws exception if any 'trap' row occurs.
        /// </summary>
        /// <typeparam name="TEntity">Loaded entities type.</typeparam>
        /// <param name="command">Tik command executed to load.</param>
        /// <param name="durationSec">Loading period.</param>
        /// <returns>List (or empty list) of loaded entities.</returns>
        /// <seealso cref="TikConnectionExtensions.LoadWithDuration{TEntity}(ITikConnection, int, ITikCommandParameter[])"/>
        public static IEnumerable <TEntity> LoadWithDuration <TEntity>(this ITikCommand command, int durationSec)
            where TEntity : new()
        {
            Guard.ArgumentNotNull(command, "command");

            var responseSentences = command.ExecuteListWithDuration(durationSec);

            return(responseSentences.Select(sentence => CreateObject <TEntity>(sentence)).ToList());
        }