コード例 #1
0
        //Available on all HTTP Verbs (GET, POST, PUT, DELETE, etc) and endpoints JSON, XMl, JSV, etc
        public object Any(TwitterFriends request)
        {
            if (request.UserId.IsNullOrEmpty() && request.ScreenName.IsNullOrEmpty())
            {
                throw new ArgumentNullException("UserId or UserName is required");
            }

            var hasId = !request.UserId.IsNullOrEmpty();

            //Create a unique cache key for this request
            var cacheKey = "cache:User:"******"Id:" + request.UserId : "Name:" + request.ScreenName)
                           + ":skip:" + request.Skip
                           + ":friends";

            //This caches and returns the most optimal result the browser can handle, e.g.
            //If the browser requests json and accepts deflate - it returns a deflated json payload from cache
            return(base.Request.ToOptimizedResultUsingCache(Cache, cacheKey, () =>
                                                            new TwitterFriendsResponse
            {
                Results = hasId
                        ? AuthTwitterGateway.GetFriends(ulong.Parse(request.UserId), request.Skip)
                        : AuthTwitterGateway.GetFriends(request.ScreenName, request.Skip)
            }));
        }
コード例 #2
0
        //Available on all HTTP Verbs (GET, POST, PUT, DELETE, etc) and endpoints JSON, XMl, JSV, etc
        public object Any(TwitterFriends request)
        {
            if (request.UserId.IsNullOrEmpty() && request.ScreenName.IsNullOrEmpty())
                throw new ArgumentNullException("UserId or UserName is required");

            var hasId = !request.UserId.IsNullOrEmpty();

            //Create a unique cache key for this request
            var cacheKey = "cache:User:"******"Id:" + request.UserId : "Name:" + request.ScreenName)
                + ":skip:" + request.Skip
                + ":friends";

            //This caches and returns the most optimal result the browser can handle, e.g.
            //If the browser requests json and accepts deflate - it returns a deflated json payload from cache
            return base.RequestContext.ToOptimizedResultUsingCache(Cache, cacheKey, () =>
                new TwitterFriendsResponse {
                    Results = hasId
                        ? TwitterGateway.GetFriends(ulong.Parse(request.UserId), request.Skip)
                        : TwitterGateway.GetFriends(request.ScreenName, request.Skip)
                });
        }