internal static string matchSingleVCardPrefixedField(string prefix, string rawText, bool trim)
 {
     string[] array = VCardResultParser.matchVCardPrefixedField(prefix, rawText, trim);
     if (array != null)
     {
         return(array[0]);
     }
     return(null);
 }
Esempio n. 2
0
        private static string[] matchVCardPrefixedField(string prefix, string rawText, bool trim)
        {
            IList <IList <string> > values = VCardResultParser.matchVCardPrefixedField(prefix, rawText, trim, false);

            if (values == null || values.Count == 0)
            {
                return(null);
            }
            int size = values.Count;

            string[] result = new string[size];
            for (int i = 0; i < size; i++)
            {
                result[i] = values[i][0];
            }
            return(result);
        }
        public static AddressBookParsedResult parse(Result result)
        {
            string text = result.Text;

            if (text == null || !text.StartsWith("BEGIN:VCARD"))
            {
                return(null);
            }
            string[] array = VCardResultParser.matchVCardPrefixedField("FN", text, true);
            if (array == null)
            {
                array = VCardResultParser.matchVCardPrefixedField("N", text, true);
                VCardResultParser.formatNames(array);
            }
            string[] phoneNumbers = VCardResultParser.matchVCardPrefixedField("TEL", text, true);
            string[] emails       = VCardResultParser.matchVCardPrefixedField("EMAIL", text, true);
            string   note         = VCardResultParser.matchSingleVCardPrefixedField("NOTE", text, false);

            string[] array2 = VCardResultParser.matchVCardPrefixedField("ADR", text, true);
            if (array2 != null)
            {
                for (int i = 0; i < array2.Length; i++)
                {
                    array2[i] = VCardResultParser.formatAddress(array2[i]);
                }
            }
            string org   = VCardResultParser.matchSingleVCardPrefixedField("ORG", text, true);
            string text2 = VCardResultParser.matchSingleVCardPrefixedField("BDAY", text, true);

            if (!VCardResultParser.isLikeVCardDate(text2))
            {
                text2 = null;
            }
            string title = VCardResultParser.matchSingleVCardPrefixedField("TITLE", text, true);
            string url   = VCardResultParser.matchSingleVCardPrefixedField("URL", text, true);

            return(new AddressBookParsedResult(array, null, phoneNumbers, emails, note, array2, org, text2, title, url));
        }