Exemplo n.º 1
0
        /// <summary>
        /// Compare() is to be used to help with implementation of IComparer for sorting operations.
        /// </summary>
        public static int Compare(ParsingParams xPrams, ParsingParams yPrams)
        {
            if (xPrams == null && yPrams == null)
            {
                return(0);
            }

            int retval = xPrams == null ? -1 : (yPrams == null ? 1 : 0);

            if (retval == 0)
            {
                string[][] xNames = xPrams.RenameNamespaceMap;
                string[][] yNames = yPrams.RenameNamespaceMap;
                retval = System.Collections.Comparer.Default.Compare(xNames.Length, yNames.Length);
                if (retval == 0)
                {
                    for (int i = 0; i < xNames.Length && retval == 0; i++)
                    {
                        retval = System.Collections.Comparer.Default.Compare(xNames[i].Length, yNames[i].Length);
                        if (retval == 0)
                        {
                            for (int j = 0; j < xNames[i].Length; j++)
                            {
                                retval = System.Collections.Comparer.Default.Compare(xNames[i][j], yNames[i][j]);
                            }
                        }
                    }
                }
            }
            return(retval);
        }
Exemplo n.º 2
0
 public FileParser(string fileName, ParsingParams prams, bool process, bool imported, string[] searchDirs, bool throwOnError)
 {
     FileParser._throwOnError = throwOnError;
     this.imported            = imported;
     this.prams      = prams;
     this.fileName   = ResolveFile(fileName, searchDirs);
     this.searchDirs = searchDirs.Concat(new string[] { Path.GetDirectoryName(this.fileName) }).Distinct().ToArray();
     if (process)
     {
         ProcessFile();
     }
 }
Exemplo n.º 3
0
        public FileParser(string fileName, ParsingParams prams, bool process, bool imported, string[] searchDirs, bool throwOnError)
        {
            if (searchDirs == null)
            {
                searchDirs = new string[0];
            }

            FileParser.throwOnError = throwOnError;
            this.Imported           = imported;
            this.prams      = prams;
            this.fileName   = ResolveFile(fileName, searchDirs);
            this.SearchDirs = searchDirs.ConcatWith(this.fileName.GetDirName())
                              .RemovePathDuplicates();
            if (process)
            {
                ProcessFile();
            }
        }
Exemplo n.º 4
0
        public int Compare(FileParser x, FileParser y)
        {
            if (x == null && y == null)
            {
                return(0);
            }

            int retval = x == null ? -1 : (y == null ? 1 : 0);

            if (retval == 0)
            {
                retval = string.Compare(x.fileName, y.fileName, true);
                if (retval == 0)
                {
                    retval = ParsingParams.Compare(x.prams, y.prams);
                }
            }

            return(retval);
        }