Пример #1
0
 /// <summary>
 /// Get status
 /// </summary>
 private static TwitterStatus GetStatus(this CredentialProvider provider, string partialUri, CredentialProvider.RequestMethod method, IEnumerable<KeyValuePair<string, string>> para)
 {
     var doc = provider.RequestAPIv1(partialUri, method, para);
     if (doc == null)
         return null;
     return TwitterStatus.FromNode(doc.Root);
 }
Пример #2
0
 /// <summary>
 /// Get status
 /// </summary>
 private static TwitterStatus GetStatus(this CredentialProvider provider, string partialUriFormat, CredentialProvider.RequestMethod method, long id)
 {
     string partialUri = string.Format(partialUriFormat, id);
     List<KeyValuePair<string, string>> para = new List<KeyValuePair<string, string>>();
     para.Add(new KeyValuePair<string, string>("include_entitis", "true"));
     var doc = provider.RequestAPIv1(partialUri, method, para);
     if (doc == null)
         return null;
     return TwitterStatus.FromNode(doc.Root);
 }
Пример #3
0
 /// <summary>
 /// Get user with full params
 /// </summary>
 private static TwitterUser GetUser(this CredentialProvider provider, string partialUri, CredentialProvider.RequestMethod method, long? userId, string screenName)
 {
     var para = new List<KeyValuePair<string, string>>();
     if (userId != null)
     {
         para.Add(new KeyValuePair<string, string>("user_id", userId.ToString()));
     }
     if (screenName != null)
     {
         para.Add(new KeyValuePair<string, string>("screen_name", screenName));
     }
     var doc = provider.RequestAPIv1(partialUri, method, para);
     if (doc == null)
         return null;
     return TwitterUser.FromNode(doc.Root);
 }
Пример #4
0
 internal StreamingConnection(StreamingCore core, CredentialProvider provider, HttpWebRequest usedRequest, Stream strm, int timeoutSec)
 {
     if (core == null)
         throw new ArgumentNullException("core");
     if (provider == null)
         throw new ArgumentNullException("provider");
     if (usedRequest == null)
         throw new ArgumentException("usedRequest");
     if (strm == null)
         throw new ArgumentNullException("strm");
     this.timeoutValue = timeoutSec;
     this.parentCore = core;
     this.Provider = provider;
     this.receiveStream = strm;
     this.usedRequest = usedRequest;
     this.streamReceiver = new Thread(StreamingThread);
     this.streamReceiver.Start();
     // タイムアウト用タイマー
     timeoutTimer = new Timer(TimeoutCountUp, null, 1000, 1000);
 }
Пример #5
0
 /// <summary>
 /// ストリーミング接続を行います。
 /// </summary>
 public StreamingConnection ConnectNew(
     CredentialProvider provider,
     StreamingDescription desc)
 {
     HttpWebRequest request;
     var streaming = provider.RequestStreamingAPI(
         GetStreamingUri(desc.Type),
         GetStreamingMethod(desc.Type),
         BuildArguments(desc), out request);
     if (streaming == null)
         throw new InvalidOperationException("接続に失敗しました。");
     var con = new StreamingConnection(this, provider, request, streaming, desc.Timeout);
     if (con == null)
         throw new InvalidOperationException("受信開始に失敗しました。");
     lock (conLock)
     {
         connections.Add(con);
     }
     return con;
 }
Пример #6
0
 internal void EnqueueReceivedObject(CredentialProvider source, string json)
 {
     lock (waiterQueue)
     {
         waiterQueue.Enqueue(new Tuple<CredentialProvider, string>(source, json));
     }
     jsonParseWaiter.Set();
 }
Пример #7
0
 /// <summary>
 /// Formatting target uri and request api
 /// </summary>
 /// <remarks>
 /// For twitter api version 1
 /// </remarks>
 private static XDocument RequestAPIv1(this CredentialProvider provider, string partial, CredentialProvider.RequestMethod method, IEnumerable<KeyValuePair<string, string>> param)
 {
     var target = TwitterUri + (partial.EndsWith("/") ? partial.Substring(1) : partial);
     return provider.RequestAPI(target, method, param);
 }