BF2Statistics.Utilities.SqlFile.ExtractQueries C# (CSharp) Method

ExtractQueries() public static method

Takes an array of lines (most likely from an sql file), and extracts the queries (mulit or single line), and returns them
public static ExtractQueries ( string Lines ) : List
Lines string
return List
        public static List<string> ExtractQueries(string[] Lines)
        {
            List<string> Queries = new List<string>();
            StringBuilder Query = new StringBuilder();

            // Add each query to the Queries list
            foreach (string line in Lines)
            {
                // Trim line, and make sure its not a comment of any kind
                string TrimLine = line.Trim();
                if (!String.IsNullOrEmpty(TrimLine) && !TrimLine.StartsWith("#") && !TrimLine.StartsWith("--"))
                {
                    // Is the query complete?
                    if (TrimLine.EndsWith(";"))
                    {
                        Query.Append(TrimLine);
                        Queries.Add(Query.ToString());
                        Query.Clear();
                    }
                    else
                        Query.Append(TrimLine);
                }
            }

            return Queries;
        }