예제 #1
0
 /// <summary>
 /// 指定した式ツリーを使用して図書館検索を実行します。
 /// </summary>
 /// <param name="expression">式ツリーを示す <see cref="System.Linq.Expressions.Expression"/>。</param>
 /// <returns>実行結果を示す <see cref="System.Object"/>。</returns>
 public override object Execute(Expression expression)
 {
     using (var client = new HttpClient()) {
         var builder = new CalilLibraryExpressionBuilder()
         {
             AppKey = this.AppKey,
             Format = this.Format,
         };
         var expr = builder.Create(expression);
         var uri  = new UriQueryParser(expr).Parse(this.BaseUriString);
         var text = client.GetStringAsync(uri).Wait <string>();
         if (text == null)
         {
             return(null);
         }
         return(CalilLibraryResult.Parse(text));
     }
 }
예제 #2
0
 /// <summary>
 /// 指定した式ツリーを使用して蔵書検索を実行します。
 /// </summary>
 /// <param name="expression">式ツリーを示す <see cref="System.Linq.Expressions.Expression"/>。</param>
 /// <returns>実行結果を示す <see cref="System.Object"/>。</returns>
 public override object Execute(Expression expression)
 {
     using (var client = new HttpClient()) {
         var builder = new CalilCheckExpressionBuilder()
         {
             AppKey = this.AppKey,
             Format = this.Format,
         };
         var expr = builder.Create(expression);
         while (true)
         {
             var uri  = new UriQueryParser(expr).Parse(this.BaseUriString);
             var text = client.GetStringAsync(uri).Wait <string>();
             if (text == null)
             {
                 return(null);
             }
             var xml = XElement.Parse(text, LoadOptions.None);
             if ((bool)xml.Element("continue") == true)
             {
                 if (this.OnPolling == null ||
                     this.OnPolling.Invoke(CalilCheckResult.Parse(xml)) != true)
                 {
                     return(null);
                 }
                 Task.Delay(PollingInterval).Wait();
                 expr = builder.Create((string)xml.Element("session"));
             }
             else
             {
                 return(CalilCheckResult.Parse(xml));
             }
         }
         ;
     }
 }