Esempio n. 1
0
        private static string GetProjectFileInfo(Project.NodejsProjectNode project)
        {
            var fileTypeInfo = new Dictionary<string, FileTypeInfo>();
            foreach (var node in project.DiskNodes) {
                var file = node.Key;
                var matchedExt = _interestingFileExtensions.Where(ext => file.EndsWith(ext, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

                if (!string.IsNullOrEmpty(matchedExt)) {
                    var recordKey = string.Format("{0} ({1})", matchedExt, node.Value.ItemNode?.IsExcluded ?? true ? "excluded from project" : "included in project");
                    FileTypeInfo record;
                    if (!fileTypeInfo.TryGetValue(recordKey, out record)) {
                        record = fileTypeInfo[recordKey] = new FileTypeInfo();
                    }
                    record.UpdateForFile(file);
                }
            }

            var res = new StringBuilder();

            res.AppendLine("Project Info:");
            foreach (var entry in fileTypeInfo) {
                res.AppendLine(Indent(1, entry.Key + ":"));
                res.AppendLine(Indent(2, "Number of Files: " + entry.Value.Count));
                res.AppendLine(Indent(2, "Average Line Count: " + entry.Value.AverageLineLength));
                res.AppendLine(Indent(2, "Max Line Count: " + entry.Value.MaxLineLength));
            }

            return res.ToString();
        }
Esempio n. 2
0
            public bool IsSameOrSubtype(FileTypeInfo possibleSubtype)
            {
                if (this == possibleSubtype)
                    return true;

                if (subtypes != null)
                {
                    foreach (FileTypeInfo subtype in Subtypes)
                    {
                        if (subtype.IsSameOrSubtype(possibleSubtype))
                            return true;
                    }
                }

                return false;
            }
Esempio n. 3
0
 public FileWrapper(DirectoryInfo rootDirectory, string relativePath, FileTypeInfo fileTypeInfo)
 {
     _fullFilePath = Path.Combine(rootDirectory.FullName, relativePath);
     _fileTypeInfo = fileTypeInfo;
 }
Esempio n. 4
0
 public void AddSubtype(FileTypeInfo subtype)
 {
     if (subtypes == null)
         subtypes = new List<FileTypeInfo>();
     subtypes.Add(subtype);
 }
Esempio n. 5
0
        private void DefineFileTypes()
        {
            var oneWeek = _enableCaching ? TimeSpan.FromDays(7) : (TimeSpan?)null;
            var oneHour = _enableCaching ? TimeSpan.FromHours(1) : (TimeSpan?)null;

            var fileTypes = new Dictionary<string, FileTypeInfo>()
            {
                {".avi", new FileTypeInfo{MimeType = "video/avi", Expiry = oneWeek}},
                {".mov", new FileTypeInfo{MimeType = "video/quicktime", Expiry = oneWeek}},
                {".mp3", new FileTypeInfo{MimeType = "video/mpeg",  Expiry = oneWeek}},

                {".bmp", new FileTypeInfo{MimeType = "image/bmp",  Expiry = oneWeek}},
                {".ico", new FileTypeInfo{MimeType = "image/ico",  Expiry = oneWeek}},
                {".jpg", new FileTypeInfo{MimeType = "image/jpeg",  Expiry = oneWeek}},
                {".jfif", new FileTypeInfo{MimeType = "image/jpeg",  Expiry = oneWeek}},
                {".jpeg", new FileTypeInfo{MimeType = "image/jpeg",  Expiry = oneWeek}},
                {".png", new FileTypeInfo{MimeType = "image/png",  Expiry = oneWeek}},
                {".tif", new FileTypeInfo{MimeType = "image/tif",  Expiry = oneWeek}},
                {".tiff", new FileTypeInfo{MimeType = "image/tif",  Expiry = oneWeek}},
                {".gif", new FileTypeInfo{MimeType = "image/gif",  Expiry = oneWeek}},

                {".html", new FileTypeInfo{MimeType = "text/html", Expiry = oneHour, Processing = FileProcessing.Html}},
                {".txt", new FileTypeInfo{MimeType = "text/plain"}},
                {".css", new FileTypeInfo{MimeType = "text/css", Expiry = oneWeek, Processing = FileProcessing.Css}},

                {".js", new FileTypeInfo{MimeType = "application/javascript", Expiry = oneHour, Processing = FileProcessing.JavaScript}},
                {".dart", new FileTypeInfo{MimeType = "application/dart", Expiry = oneHour, Processing = FileProcessing.Dart}},
            };

            fileTypes.Add(".htm", fileTypes[".html"]);
            fileTypes.Add(".shtml", fileTypes[".html"]);

            _defaultFileTypeInfo = fileTypes[".html"];
            _fileTypes = fileTypes;
        }