private static bool HasPerson(string sec, ParsedIni parsedIni, PicasaPerson picasaPerson) { var facesValue = parsedIni.TryGetSetting(sec, "faces"); if (facesValue == null) { return(false); } var personIds = facesValue.Split(';') .SelectMany(pairs => pairs.Split(',').Skip(1).Take(1)); return(personIds.Intersect(picasaPerson.FocusIds).Any()); }
private static IEnumerable <string> WithPersonFromPicasaIni(this string picasaIniPath, PicasaPerson picasaPerson) { var dir = Path.GetDirectoryName(picasaIniPath); try { var parsedIni = new ParsedIni(picasaIniPath); var filesInIni = parsedIni.EnumSections(); var filesWithPerson = filesInIni.Where(sec => HasPerson(sec, parsedIni, picasaPerson)); var fullPathsWithPerson = filesWithPerson.Select(fn => Path.Combine(dir, fn)); var existingPersonFiles = fullPathsWithPerson.Where(File.Exists).ToArray(); return(existingPersonFiles); //return !existingPersonFiles.Any() ? new String[0] : new[] { picasaIniPath }.Concat(existingPersonFiles); } catch (Exception e) { Console.Error.WriteLine("Failed to parse {0}: {1}", picasaIniPath, e); return(new string[0]); } }
private static bool IsStarred(string sec, ParsedIni picasaIni) { var starValue = picasaIni.TryGetSetting(sec, "star"); return(starValue != null && starValue.Equals("yes", StringComparison.InvariantCultureIgnoreCase)); }