private static Dictionary <int, List <MyFileInfo> > GenerateExistingAVs(List <AV> avs) { Dictionary <int, List <MyFileInfo> > fileContainer = new Dictionary <int, List <MyFileInfo> >(); var oneOneFiveFiles = OneOneFiveService.Get115FilesModel(); List <OneOneFiveItemWIthMatchId> matches = new List <OneOneFiveItemWIthMatchId>(); avs.ForEach(x => x.AvIdAndName = x.ID + "-" + x.Name); foreach (var file in oneOneFiveFiles) { if (file.n.Split('-').Length >= 3) { file.AvId = file.n.Split('-')[0] + "-" + file.n.Split('-')[1]; file.AvName = file.n.Replace(file.AvId, "").Substring(1).Replace("." + file.ico, "").Replace("-C", ""); } } foreach (var file in oneOneFiveFiles.Where(x => !string.IsNullOrEmpty(x.AvName))) { var matchList = avs.FirstOrDefault(x => x.Name == file.AvName); AV match = null; if (matchList != null) { match = matchList; } if (match != null) { matches.Add(new OneOneFiveItemWIthMatchId() { ico = file.ico, n = file.n, s = file.s, MatchId = match.AvId }); } } foreach (var match in matches) { if (fileContainer.ContainsKey(match.MatchId)) { fileContainer[match.MatchId].Add(new MyFileInfo() { Extension = "." + match.ico, FullName = match.n, Length = match.s, Name = match.n }); } else { fileContainer.Add(match.MatchId, new List <MyFileInfo> { new MyFileInfo() { Extension = "." + match.ico, FullName = match.n, Length = match.s, Name = match.n } }); } } return(fileContainer); }