Exemple #1
0
        /// <summary>
        /// <see cref="Karamem0.LinqToCalil.CalilLibraryResult.Geocode"/> プロパティの緯度を返します。
        /// </summary>
        /// <param name="target">図書館検索の実行結果を示す <see cref="Karamem0.LinqToCalil.CalilLibraryResult"/>。</param>
        /// <returns>緯度を示す null 許容型の <see cref="System.Double"/>。</returns>
        public static double?Latitude(this CalilLibraryResult target)
        {
            var match = Regex.Match(target.Geocode, "^(\\d+\\.?\\d*),(\\d+\\.?\\d*)$");

            if (match.Success == true)
            {
                return(double.Parse(match.Groups[2].Value));
            }
            return(null);
        }
Exemple #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 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));
     }
 }