示例#1
0
        /// <summary>
        /// Tries to parse value into sync token.
        /// </summary>
        /// <param name="value">Value to parse.</param>
        /// <param name="tokenType">Token type.</param>
        /// <param name="token">out SyncToken.</param>
        /// <returns></returns>
        public static bool TryParseFromUrl(string value, SyncTokenType tokenType, out ISyncToken token)
        {
            token = null;
            if (string.IsNullOrEmpty(value))
            {
                return(false);
            }

            int startIndex = value.IndexOf(SyncToken.GetTokenPrefix(tokenType), StringComparison.OrdinalIgnoreCase);

            if (startIndex == -1)
            {
                return(false);
            }

            int    endIndex   = startIndex + SyncToken.GetTokenPrefix(tokenType).Length;
            string tokenValue = value.Substring(endIndex);

            if (tokenValue.IndexOf("&", StringComparison.Ordinal) != -1)
            {
                tokenValue = tokenValue.Split('&')[0];
            }

            token = new SyncToken(tokenValue, tokenType);
            return(true);
        }
        /// <summary>
        /// Create new instance of <see cref="SyncItemCollection{T}"/>
        /// </summary>
        /// <param name="entityResponseCollection">Response collection.</param>
        internal SyncFolderItemsCollection(SyncEntityResponseCollection <T> entityResponseCollection, ExchangeService exchangeService, MailboxId mailboxId)
            : base(entityResponseCollection)
        {
            if (entityResponseCollection != null)
            {
                // if token isn't delta, then it is skip.
                if (!SyncToken.TryParseFromUrl(entityResponseCollection.ODataDeltaLink, SyncTokenType.DeltaToken, out this.syncToken))
                {
                    SyncToken.TryParseFromUrl(entityResponseCollection.ODataNextLink, SyncTokenType.SkipToken, out this.syncToken);
                }

                // Since property bag will be 'dirty' after loading
                // properties from JSON, reset change tracking since
                // latest version is already in the collection.
                entityResponseCollection.RegisterServiceAndResetChangeTracking(
                    exchangeService,
                    mailboxId);
            }
        }
示例#3
0
 /// <summary>
 /// Tries to parse value of Url query into <see cref="ISyncToken"/>
 /// </summary>
 /// <param name="url"></param>
 /// <param name="tokenType"></param>
 /// <param name="token"></param>
 /// <returns></returns>
 public static bool TryParseFromUrl(Uri url, SyncTokenType tokenType, out ISyncToken token)
 {
     return(SyncToken.TryParseFromUrl(url.Query, tokenType, out token));
 }