Beispiel #1
0
        /// <summary>
        /// Reads the full list of contacts from the online storage
        /// </summary>
        /// <param name="clientFolderName">represents a path to the data</param>
        /// <param name="result">the list that will be filled with the contacts</param>
        /// <returns>the list of contacts that has been read from the online storage</returns>
        protected override List <SyncBase.DetailData.StdElement> ReadFullList(string clientFolderName, List <SyncBase.DetailData.StdElement> result)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }

            var client    = new ContactServiceClient();
            var formatter = new BinaryFormatter();

            using (var stream = new MemoryStream())
            {
                var all = client.GetAll(clientFolderName);
                all.CopyTo(stream);
                stream.Position = 0;

                var stdContacts = formatter.Deserialize(stream) as List <StdElement>;

                if (stdContacts != null)
                {
                    result.AddRange(stdContacts);
                }
            }

            return(result);
        }