示例#1
0
        Task <RouterState> readCache(CancellationToken cancellationToken)
        {
            try
            {
                var cache = AVClient.DecodeQueryString(AVClient.ApplicationSettings["RouterState"] as string);

                var routerState = new RouterState()
                {
                    groupId   = cache["groupId"] as string,
                    server    = cache["server"] as string,
                    secondary = cache["secondary"] as string,
                    ttl       = long.Parse(cache["ttl"]),
                };

                return(Task.FromResult <RouterState>(routerState));
            }
            catch
            {
                return(Task.FromResult <RouterState>(null));
            }
        }
        /// <summary>
        /// AVs a uri, looking for a base uri that represents facebook login completion, and then
        /// converting the query string into a dictionary of key-value pairs. (e.g. access_token)
        /// </summary>
        private bool TryAVOAuthCallbackUrl(Uri uri, out IDictionary <string, string> result)
        {
            if (!uri.AbsoluteUri.StartsWith((ResponseUrlOverride ?? ResponseUrl).AbsoluteUri) ||
                uri.Fragment == null)
            {
                result = null;
                return(false);
            }
            string fragmentOrQuery;

            if (!string.IsNullOrEmpty(uri.Fragment))
            {
                fragmentOrQuery = uri.Fragment;
            }
            else
            {
                fragmentOrQuery = uri.Query;
            }
            // Trim the # or ? off of the fragment/query and then parse the querystring
            result = AVClient.DecodeQueryString(fragmentOrQuery.Substring(1));
            return(true);
        }