Esempio n. 1
0
            /// <summary>
            /// Constructor with parameters
            /// </summary>
            /// <param name="messageType">Message type</param>
            /// <param name="format">Optional text to display</param>
            /// <param name="args">Optional parameters</param>
            public OutlineWrapper(SledMessageType messageType, string format, params object[] args)
            {
                m_timer = new SledHiPerfTimer();
                m_timer.Start();

                m_message     = string.Format(format, args);
                m_messageType = messageType;
            }
        private static IEnumerable<SledSyntaxCheckerEntry> CheckFiles(IEnumerable<SledProjectFilesFileType> files, SledSyntaxCheckerVerbosity verbosity, object userData, SledUtil.BoolWrapper shouldCancel)
        {
            SledHiPerfTimer timer = null;

            var enumeratedFiles = new List<SledProjectFilesFileType>(files);
            
            var errors = new List<SledSyntaxCheckerEntry>();
            var fileCount = enumeratedFiles.Count;

            try
            {
                if (verbosity > SledSyntaxCheckerVerbosity.None)
                {
                    timer = new SledHiPerfTimer();
                    timer.Start();
                }
                
                var allWorkItems = new SyntaxCheckerWorkItem[fileCount];

                for (var i = 0; i < fileCount; ++i)
                    allWorkItems[i] = new SyntaxCheckerWorkItem(enumeratedFiles[i], verbosity, userData, shouldCancel);

                var workerCount = Math.Min(ProducerConsumerQueue.WorkerCount, fileCount);
                using (var pcQueue = new ProducerConsumerQueue(workerCount, shouldCancel))
                {
                    pcQueue.EnqueueWorkItems(allWorkItems);
                }

                if (shouldCancel.Value)
                    return EmptyEnumerable<SledSyntaxCheckerEntry>.Instance;

                // gather all results from all work items
                foreach (var workItem in allWorkItems)
                    errors.AddRange(workItem.Errors);
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLine(
                    SledMessageType.Error,
                    "{0}: Exception syntax checking files: {1}",
                    typeof(SledLuaSyntaxCheckerService), ex.Message);
            }
            finally
            {
                if ((timer != null) && (!shouldCancel.Value))
                {
                    SledOutDevice.OutLine(
                        SledMessageType.Info,
                        "[Lua] Syntax checked {0} files in {1} seconds",
                        fileCount, timer.Elapsed);
                }
            }

            return errors;
        }
Esempio n. 3
0
            /// <summary>
            /// Constructor with parameters
            /// </summary>
            /// <param name="messageType">Message type</param>
            /// <param name="format">Optional text to display</param>
            /// <param name="args">Optional parameters</param>
            public OutlineWrapper(SledMessageType messageType, string format, params object[] args)
            {
                m_timer = new SledHiPerfTimer();
                m_timer.Start();

                m_message = string.Format(format, args);
                m_messageType = messageType;
            }