Esempio n. 1
0
        /// <summary>
        /// Synchronize multiple types with a single roundtrip
        /// </summary>
        /// <param name="typeIDs">TypeIds to sync</param>
        /// <param name="maxAgeInSeconds">View age</param>
        /// <returns>A list of type ids actually synchronized</returns>
        public IAsyncOperation <IList <string> > SynchronizeTypesAsync(IList <string> typeIDs, int maxAgeInSeconds)
        {
            if (typeIDs.IsNullOrEmpty())
            {
                throw new ArgumentException("typeIDs");
            }
            if (maxAgeInSeconds < 0)
            {
                throw new ArgumentException("maxAgeInSeconds");
            }

            return(AsyncInfo.Run <IList <string> >(async cancelToken =>
            {
                IList <SynchronizedType> sTypes = await this.GetMultipleAsync(typeIDs);
                SynchronizedViewSynchronizer synchronizer = new SynchronizedViewSynchronizer(m_recordStore.Record, maxAgeInSeconds);
                synchronizer.MaxAgeInSeconds = maxAgeInSeconds;

                IList <ISynchronizedView> synchronized = await synchronizer.SynchronizeAsync(sTypes.Cast <ISynchronizedView>().ToList());
                if (synchronized.IsNullOrEmpty())
                {
                    return null;
                }

                string[] syncedIDs = (from view in synchronized
                                      select((SynchronizedType)view).TypeID).ToArray();

                return syncedIDs;
            }));
        }
        /// <summary>
        /// Synchronize multiple types with a single roundtrip
        /// </summary>
        /// <param name="typeIDs">TypeIds to sync</param>
        /// <param name="maxAgeInSeconds">View age</param>
        /// <returns>A list of type ids actually synchronized</returns>
        public IAsyncOperation<IList<string>> SynchronizeTypesAsync(IList<string> typeIDs, int maxAgeInSeconds)
        {
            if (typeIDs.IsNullOrEmpty())
            {
                throw new ArgumentException("typeIDs");
            }
            if (maxAgeInSeconds < 0)
            {
                throw new ArgumentException("maxAgeInSeconds");
            }

            return AsyncInfo.Run<IList<string>>(async cancelToken =>
            {
                IList<SynchronizedType> sTypes = await this.GetMultipleAsync(typeIDs);
                SynchronizedViewSynchronizer synchronizer = new SynchronizedViewSynchronizer(m_recordStore.Record, maxAgeInSeconds);
                synchronizer.MaxAgeInSeconds = maxAgeInSeconds;

                IList<ISynchronizedView> synchronized = await synchronizer.SynchronizeAsync(sTypes.Cast<ISynchronizedView>().ToList());
                if (synchronized.IsNullOrEmpty())
                {
                    return null;
                }
                
                string[] syncedIDs = (from view in synchronized
                        select ((SynchronizedType) view).TypeID).ToArray();

                return syncedIDs;
            });
        }