Example #1
0
 public static bool HasSameTelNumber(VCard rec1,VCard rec2)
 {
     foreach(var tel1 in rec1.TelProperties)
     {
         if (rec2.TelProperties.Any(x => x.NormalizedNumber == tel1.NormalizedNumber))
             return true;
     }
     return false;
 }
Example #2
0
        public static bool HasSameName(VCard rec1, VCard rec2)
        {
            if (rec1.N==null || rec1.N==null)
                return false;

            return string.Equals(rec1.N.Name, rec1.N.Name, StringComparison.InvariantCultureIgnoreCase)
                && string.Equals(rec1.N.GivenName, rec1.N.GivenName, StringComparison.InvariantCultureIgnoreCase)
                && string.Equals(rec1.N.AdditionalNames, rec1.N.AdditionalNames, StringComparison.InvariantCultureIgnoreCase)
                && string.Equals(rec1.N.HonorificPrefixes, rec1.N.HonorificPrefixes, StringComparison.InvariantCultureIgnoreCase)
                && string.Equals(rec1.N.HonorificSuffixes, rec1.N.HonorificSuffixes, StringComparison.InvariantCultureIgnoreCase);
        }
Example #3
0
        public void basicTests()
        {
            List<VCard> cards = new List<VCard>(VCardFileProcessor.ReadVCards(VCARDS));
            var newC = new VCard();
            newC.Properties.Add(new NProperty("doe", "john", "test1", "Mr.", "San"));
            newC.Properties.Add(new TelProperty("987654321", "Cell"));
            newC.Properties.Add(new TelProperty("+420123456789", "HOME"));
            cards.Add(newC);

            Assert.IsTrue(VCardUtils.HasSameTelNumber(cards[0], newC));
            Assert.IsTrue(VCardUtils.HasSameName(cards[0], newC));

            var simCards = VCardUtils.GetSimilarRecords(cards, VCardUtils.HasSameTelNumber);
            Assert.IsTrue(simCards.Count() == 1 && simCards.First().First() == cards[0] && simCards.First().Skip(1).First() == newC);
        }
Example #4
0
        private static IEnumerable<VCard> CreateVCards(IEnumerable<ParsedLine> parsedLines)
        {
            List<VCard> res = new List<VCard>();

            VCard rec = null;
            foreach (var pl in parsedLines)
            {
                if (pl.Name == "BEGIN" && pl.Value == "VCARD")
                    rec = new VCard();
                else if (pl.Name == "END" && pl.Value == "VCARD")
                {
                    res.Add(rec);
                }
                else if (rec != null)
                {
                    rec.Properties.Add(VCardFactory.CreateProperty(pl.Name, pl.Group, pl.Params, pl.Value));
                }
            }

            return res;
        }
Example #5
0
 public static string CreateText(VCard rec, bool foldLines)
 {
     return "BEGIN:VCARD\r\n" +
             string.Join("\r\n", rec.Properties.Select(x => CreateText(x, foldLines)))
             + "\r\nEND:VCARD\r\n";
 }