Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
 public AlbumIDProvider(ILocation dataRoot)
 {
     this.idMapFile = dataRoot.GetFile("idmap", ActionIfMissing.ReturnAsIs);
     this.idMap = new ConcurrentDictionary<string, AlbumDescriptor>(this.LoadMap());
 }
Esempio n. 3
0
 public IFile FindIn(ILocation location)
 {
     return fileNames
                .Select(name => location.GetFile(name))
                .FirstOrDefault(f => f != null);
 }