예제 #1
0
        private static IEnumerable <AssemblyLine> ParseInputFile(string inputFile)
        {
            var currentLineCount = 0;
            var typeLines        = new List <TypeLine>();
            var assemblyLines    = new List <AssemblyLine>();

            using (var reader = new StreamReader(inputFile))
            {
                while (!reader.EndOfStream)
                {
                    currentLineCount++;
                    var currentLine = reader.ReadLine();

                    if (string.IsNullOrEmpty(currentLine))
                    {
                        continue;
                    }
                    if (currentLine.Trim() == "")
                    {
                        continue;
                    }
                    if (currentLine.ToLower().Trim().Equals("break;"))
                    {
                        break;
                    }
                    if (currentLine.ToLower().Trim().Equals("return;"))
                    {
                        return(assemblyLines);
                    }
                    if (!currentLine.ToLower().Trim().StartsWith("//"))
                    {
                        if (AssemblyLine.IsAssembly(currentLine))
                        {
                            var assemblyLine = new AssemblyLine(currentLineCount, currentLine);
                            assemblyLines.Add(assemblyLine);
                        }
                        else if (TypeLine.IsType(currentLine))
                        {
                            if (assemblyLines.Count == 0)
                            {
                                "CryoAOP -> Error:{0}! Could not find matching assembly tag for type ... ".Error(
                                    currentLineCount.ToString());
                                "CryoAOP -> '{0}'".Error(currentLine.Trim());
                                WriteUsage();
                                return(assemblyLines);
                            }

                            var typeLine = new TypeLine(currentLineCount, currentLine);
                            assemblyLines.Last().Types.Add(typeLine);
                            typeLines.Add(typeLine);
                        }
                        else if (MethodLine.IsMethod(currentLine))
                        {
                            if (assemblyLines.Count == 0 && typeLines.Count == 0)
                            {
                                "CryoAOP -> Error:{0}! Could not find matching type tag for method ... ".Error(
                                    currentLineCount.ToString());
                                "CryoAOP -> '{0}'".Error(currentLine.Trim());
                                WriteUsage();
                                return(assemblyLines);
                            }

                            var methodLine = new MethodLine(currentLineCount, currentLine);
                            typeLines.Last().Methods.Add(methodLine);
                        }
                        else if (PropertyLine.IsProperty(currentLine))
                        {
                            if (assemblyLines.Count == 0 && typeLines.Count == 0)
                            {
                                "CryoAOP -> Error:{0}! Could not find matching type tag for property ... ".Error(
                                    currentLineCount.ToString());
                                "CryoAOP -> '{0}'".Error(currentLine.Trim());
                                WriteUsage();
                                return(assemblyLines);
                            }

                            var propertyLine = new PropertyLine(currentLineCount, currentLine);
                            typeLines.Last().Properties.Add(propertyLine);
                        }
                        else
                        {
                            "CryoAOP -> Warning:{0}! Ignoring line because entry appears to be invalid ... ".Warn(
                                currentLineCount);
                            "CryoAOP -> '{0}'".Warn(currentLine.Trim());
                        }
                    }
                }
            }
            return(assemblyLines);
        }