예제 #1
0
        private static void ReadFile(InputFile inputFile, FileReadBuilder fileReadBuilder, CodeType codeType, string defaultEncodingName)
        {
            if (inputFile != null)
            {
                var encoding = inputFile.GetEncoding(defaultEncodingName);
                if (File.Exists(inputFile.Path))
                {
                    // file exists -- read it into the string builder with the appropriate context comments added
                    ReadFileWithContext(fileReadBuilder, inputFile.Path, codeType, encoding);
                }
                else if (Directory.Exists(inputFile.Path))
                {
                    // right now, just look for .JS for JavaScript and .CSS for Stylesheets.
                    // if we don't know what type, ask for everything!
                    var searchPattern = codeType == CodeType.JavaScript
                        ? "*.js"
                        : codeType == CodeType.StyleSheet
                        ? "*.css"
                        : "*.*";

                    ReadAllFilesWithContext(fileReadBuilder, inputFile.Path, searchPattern, codeType, encoding);
                }
            }
        }