コード例 #1
0
        /// <summary>
        /// Provide simplified ways to query a list of TwitterObject
        /// </summary>
        /// <param name="token">Token to be used</param>
        /// <param name="queryUrl">URL from which we expect results</param>
        /// <param name="objectCreatorDelegate">Method to be used to create the expected object</param>
        /// <param name="objectCreatedDelegate">Delegate to happen after a TwitterObject being created</param>
        /// <param name="wex">WebException to manage errors</param>
        /// <returns>Collection of TwitterObject retrieved from the query</returns>
        public static List <T> GetListOfTwitterObject <T>(IToken token,
                                                          string queryUrl,
                                                          ObjectCreatorDelegate <T> objectCreatorDelegate,
                                                          ObjectCreatedDelegate <T> objectCreatedDelegate = null,
                                                          WebExceptionHandlingDelegate wex = null)
        {
            if (token == null || objectCreatorDelegate == null)
            {
                return(null);
            }

            List <T> result = new List <T>();

            ObjectResponseDelegate objectDelegate = delegate(Dictionary <string, object> objectContent)
            {
                T newObject = objectCreatorDelegate(objectContent);

                if (objectCreatedDelegate != null)
                {
                    objectCreatedDelegate(newObject);
                }

                result.Add(newObject);
            };

            token.ExecuteGETQuery(queryUrl, objectDelegate, wex);

            return(result);
        }
コード例 #2
0
 public void CreatePool(ObjectCreatorDelegate objectCreator)
 {
     for (var i = 0; i < _capacity; i++)
     {
         _pool.Push(objectCreator.Invoke());
     }
 }
コード例 #3
0
        private static Result <CType> GetObjectFromCreator <CType>(ObjectCreatorDelegate objectCreatorDelegate) where CType : class
        {
            var obj = objectCreatorDelegate?.Invoke() as CType;

            return(Result
                   .Success(obj)
                   .Ensure(obj => obj != null, "Unable to create instance of an object"));
        }
コード例 #4
0
        /// <summary>
        /// Provide simplified ways to query a list of Messages
        /// </summary>
        /// <param name="token">Token to be used</param>
        /// <param name="queryUrl">URL from which we expect results</param>
        /// <param name="objectCreatedDelegate">Delegate to happen after a Message being created</param>
        /// <param name="wex">WebException to manage errors</param>
        /// <returns>Collection of messages retrieved from the query</returns>
        public static List <IMessage> GetMessages(IToken token,
                                                  string queryUrl,
                                                  ObjectCreatedDelegate <IMessage> objectCreatedDelegate = null,
                                                  WebExceptionHandlingDelegate wex = null)
        {
            ObjectCreatorDelegate <IMessage> userCreator = delegate(Dictionary <string, object> data)
            {
                return(new Message(data));
            };

            return(GetListOfTwitterObject(token, queryUrl, userCreator, objectCreatedDelegate, wex));
        }
コード例 #5
0
        /// <summary>
        /// Provide simplified ways to query a list of Tweets
        /// </summary>
        /// <param name="token">Token to be used</param>
        /// <param name="queryUrl">URL from which we expect results</param>
        /// <param name="objectCreatedDelegate">Delegate to happen after a Tweet being created</param>
        /// <param name="wex">WebException to manage errors</param>
        /// <returns>Collection of tweets retrieved from the query</returns>
        public static List <ITweet> GetTweets(IToken token,
                                              string queryUrl,
                                              ObjectCreatedDelegate <ITweet> objectCreatedDelegate = null,
                                              WebExceptionHandlingDelegate wex = null)
        {
            ObjectCreatorDelegate <ITweet> tweetCreator = delegate(Dictionary <string, object> data)
            {
                return(new Tweet(data));
            };

            return(GetListOfTwitterObject(token, queryUrl, tweetCreator, objectCreatedDelegate, wex));
        }