Example #1
0
        /// <summary>
        /// Gets the set of <see cref="LogEntry"/> objects for a specified log.
        /// </summary>
        /// <param name="logKind">The log for which to retrieve the log entries.
        /// Log types can be found in the <see cref="LogType"/> class.</param>
        /// <returns>The list of <see cref="LogEntry"/> objects for the specified log.</returns>
        public ReadOnlyCollection <LogEntry> GetLog(string logKind)
        {
            List <LogEntry> entries = new List <LogEntry>();

            try
            {
                Dictionary <string, object> parameters = new Dictionary <string, object>();
                parameters.Add("type", logKind);
                Response commandResponse = this.driver.InternalExecute(DriverCommand.GetLog, parameters);

                object[] responseValue = commandResponse.Value as object[];
                if (responseValue != null)
                {
                    foreach (object rawEntry in responseValue)
                    {
                        Dictionary <string, object> entryDictionary = rawEntry as Dictionary <string, object>;
                        if (entryDictionary != null)
                        {
                            entries.Add(LogEntry.FromDictionary(entryDictionary));
                        }
                    }
                }
            }
            catch (NotImplementedException)
            {
                // Swallow for backwards compatibility
            }

            return(entries.AsReadOnly());
        }
Example #2
0
        /// <summary>
        /// Gets the set of <see cref="LogEntry"/> objects for a specified log.
        /// </summary>
        /// <param name="logKind">The log for which to retrieve the log entries.
        /// Log types can be found in the <see cref="LogType"/> class.</param>
        /// <returns>The list of <see cref="LogEntry"/> objects for the specified log.</returns>
        public ReadOnlyCollection <LogEntry> GetLog(string logKind)
        {
            List <LogEntry> entries = new List <LogEntry>();

            if (this.isLogSupported)
            {
                Dictionary <string, object> parameters = new Dictionary <string, object>();
                parameters.Add("type", logKind);
                Response commandResponse = this.driver.InternalExecute(DriverCommand.GetLog, parameters);

                object[] responseValue = commandResponse.Value as object[];
                if (responseValue != null)
                {
                    foreach (object rawEntry in responseValue)
                    {
                        Dictionary <string, object> entryDictionary = rawEntry as Dictionary <string, object>;
                        if (entryDictionary != null)
                        {
                            entries.Add(LogEntry.FromDictionary(entryDictionary));
                        }
                    }
                }
            }

            return(entries.AsReadOnly());
        }