public IEnumerable<Face> GetFaces(ILocation location) { if (this.contacts.Count == 0) // contacts.xml not loaded for some reason yield break; var ini = this.iniFileFinder.FindIn(location); if (ini == null) yield break; var parsed = this.parser.Parse(ini); var rawFaces = from pair in parsed.Items from face in pair.Value.Faces select new { FileName = pair.Key, face.ContactHash }; var contactsIndex = parsed.Contacts.ToDictionary(c => c.Hash); foreach (var rawFace in rawFaces) { var contact = contactsIndex.GetValueOrDefault(rawFace.ContactHash); if (contact == null) continue; var file = location.GetFile(rawFace.FileName); if (file == null) continue; var key = new ContactKey(contact.UserCode, contact.ID); var person = this.contacts.GetValueOrDefault(key); if (person == null) continue; yield return new Face(person, file); } }
public AlbumIDProvider(ILocation dataRoot) { this.idMapFile = dataRoot.GetFile("idmap", ActionIfMissing.ReturnAsIs); this.idMap = new ConcurrentDictionary<string, AlbumDescriptor>(this.LoadMap()); }
public IFile FindIn(ILocation location) { return fileNames .Select(name => location.GetFile(name)) .FirstOrDefault(f => f != null); }