Exemple #1
0
        public void start(object state)
        {
            TaskData td = state as TaskData;
            string filePath = td.state as string;
            Logger.debug("Thread {0} is parsing file {1}", Thread.CurrentThread.ManagedThreadId, filePath);
            // calculate executing time
            Stopwatch sw = new Stopwatch();
            sw.Reset();
            sw.Start();
            //p = new Parser(filePath);
            IParser p = new SimpleParser(filePath);
            try {
                p.read();
                p.save();
            }
            catch (Exception e) {
                Logger.error("Unable to parse file {0}", filePath);
            }
            sw.Stop();
            Logger.debug("Thread {0}: File {1} is analyzed", Thread.CurrentThread.ManagedThreadId, filePath);

            // get overview information about this file
            XElement xElem = p.xElement;
            IEnumerable<XElement> elems = xElem.Descendants("elem");
            Logger.info("Finish analyzing file {0}, {1} ms elapsed. {2} Namespaces, {3} Classes, {4} Methods are found.", filePath, sw.ElapsedMilliseconds,
                (from e in elems where e.Attribute("type").Value == SimpleParser.ELEM_NAMESPACE select e).Count(),
                (from e in elems where e.Attribute("type").Value == SimpleParser.ELEM_CLASS select e).Count(),
                (from e in elems where e.Attribute("type").Value == SimpleParser.ELEM_METHOD select e).Count());

            // finish
            td.resetEvent.Set();
        }
Exemple #2
0
        public void start(object state)
        {
            TaskData td       = state as TaskData;
            string   filePath = td.state as string;

            Logger.debug("Thread {0} is parsing file {1}", Thread.CurrentThread.ManagedThreadId, filePath);
            // calculate executing time
            Stopwatch sw = new Stopwatch();

            sw.Reset();
            sw.Start();
            //p = new Parser(filePath);
            IParser p = new SimpleParser(filePath);

            try {
                p.read();
                p.save();
            }
            catch (Exception e) {
                Logger.error("Unable to parse file {0}", filePath);
            }
            sw.Stop();
            Logger.debug("Thread {0}: File {1} is analyzed", Thread.CurrentThread.ManagedThreadId, filePath);

            // get overview information about this file
            XElement xElem = p.xElement;
            IEnumerable <XElement> elems = xElem.Descendants("elem");

            Logger.info("Finish analyzing file {0}, {1} ms elapsed. {2} Namespaces, {3} Classes, {4} Methods are found.", filePath, sw.ElapsedMilliseconds,
                        (from e in elems where e.Attribute("type").Value == SimpleParser.ELEM_NAMESPACE select e).Count(),
                        (from e in elems where e.Attribute("type").Value == SimpleParser.ELEM_CLASS select e).Count(),
                        (from e in elems where e.Attribute("type").Value == SimpleParser.ELEM_METHOD select e).Count());

            // finish
            td.resetEvent.Set();
        }