Esempio n. 1
0
        // example format: 8f7eee7d92388080=ashmind_lh,108
        private void MoveOverContacts(PicasaIni ini, IEnumerator<string> linesIterator, out bool linesIteratorEnded)
        {
            MoveOver(linesIterator, line => {
                var parsed = Regex.Match(line, "^(?<hash>[^=]+)=(?<user>[^,]+),(?<id>[^,]+)$");
                if (!parsed.Success)
                    return;

                ini.Contacts.Add(new PicasaIniContact(
                    parsed.Groups["hash"].Value,
                    parsed.Groups["user"].Value,
                    parsed.Groups["id"].Value
                ));
            }, out linesIteratorEnded);
        }
Esempio n. 2
0
        private PicasaIni Parse(IEnumerable<string> lines)
        {
            var result = new PicasaIni();
            var linesIterator = lines.GetEnumerator();

            var finished = !linesIterator.MoveNext();
            while (!finished) {
                var line = linesIterator.Current;
                if (line == "[Contacts]") {
                    MoveOverContacts(result, linesIterator, out finished);
                    continue;
                }

                if (line.StartsWith("[") && line.Contains(".")) {
                    MoveOverItem(result, line, linesIterator, out finished);
                    continue;
                }

                finished = !linesIterator.MoveNext();
            }

            return result;
        }
Esempio n. 3
0
        private void MoveOverItem(PicasaIni ini, string firstLine, IEnumerator<string> linesIterator, out bool linesIteratorEnded)
        {
            var fileName = firstLine.RemoveStart("[").RemoveEnd("]");
            var metadata = ini.Items.GetValueOrDefault(fileName);
            if (metadata == null) {
                metadata = new PicasaIniMetadata();
                ini.Items.Add(fileName, metadata);
            }

            MoveOver(linesIterator, line => {
                if (line.StartsWith("rotate=")) {
                    var rotate = int.Parse(Regex.Match(line, @"rotate\(([\d+])\)").Groups[1].Value);
                    metadata.Rotate = rotate;
                }
                else if (line.StartsWith("faces=")) {
                    var faces = line.SubstringAfter("faces=").Split(';');
                    metadata.Faces.Clear();
                    foreach (var face in faces) {
                        metadata.Faces.Add(new PicasaIniFace(face.SubstringAfter(",")));
                    }
                }
            }, out linesIteratorEnded);
        }