Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="command"></param>
        /// <param name="currentNode">A C element under either New or Update element.</param>
        protected override void AddContentToCommand(SyncMLUpdateBase command, XElement currentNode)
        {
            if (command == null)
            {
                Trace.TraceWarning("Hey, you bad. Null command.");
                return;
            }

            if (currentNode == null)
            {
                Trace.TraceWarning("Hey, r u crazy? giving me null currentNode.");
                return;
            }

            if (useBase64)
            {
                SyncMLItem item = SyncMLItem.Create();
                item.Source.LocURI.Content = currentNode.Attribute("ID").Value;
                item.Meta.Xml.Add(FormatOfBase64);
                item.Meta.Xml.Add(TypeOfText);

                UTF8Encoding byteConverter = new UTF8Encoding();
                byte[]       buffer        = byteConverter.GetBytes(VCardWriter.WriteToString(VCardSIFC.ConvertSifCToVCard(currentNode.Element("contact"))));
                item.Data.Content = Convert.ToBase64String(buffer);

                command.ItemCollection.Add(item);
            }
            else
            {
                SyncMLItem item = SyncMLItem.Create();
                item.Source.LocURI.Content = currentNode.Attribute("ID").Value;
                item.Meta.Xml.Add(xVcardType);

                item.Data.Content = VCardWriter.WriteToString(VCardSIFC.ConvertSifCToVCard(currentNode.Element("contact")));

                command.ItemCollection.Add(item);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Get contact data as vCard.
 /// </summary>
 /// <param name="contactItem"></param>
 /// <returns></returns>
 protected override string GetItemData(ContactItem item)
 {
     return(VCardWriter.WriteToString(
                VCardSIFC.ConvertSifCToVCard(XElement.Parse(
                                                 SifAgent.ReadItemToText(item)))));
 }