GetDynamicJsonObject 异常
我正在尝试按照此处的示例进行操作...但是出现异常:
“System.Uri”不包含“GetDynamicJsonObject”的定义,并且没有扩展方法“GetDynamicJsonObject”接受类型的第一个参数可以找到“System.Uri”(您是否缺少 using 指令或程序集引用?)
我已经查看了我能找到的每个在线示例,但无法弄清楚我在这里缺少什么。
private void setTimeEstimates(ref List<Object> rides, string orig)
{
string dest, googleURL;
dynamic googleResults;
int driveTime; //in seconds
using (myEntities = new RamRideOpsEntities())
{
foreach (Ride ride in rides)
{
dest = interpretAddress(ride.PickupAddress);
googleURL = "http://maps.googleapis.com/maps/api/distancematrix/json" +
"?origins=" + orig +
"&destinations=" + dest +
"&mode=driving&sensor=false";
googleResults = new Uri(googleURL).GetDynamicJsonObject(); //EXCEPTION HERE!
driveTime = googleResults.result.duration;
ride.EstTime = driveTime + BASE_WAIT_TIME;
}
myEntities.SaveChanges();
}
}
I am trying to follow the example here ...but get the exception:
'System.Uri' does not contain a definition for 'GetDynamicJsonObject' and no extension method 'GetDynamicJsonObject' accepting a first argument of type 'System.Uri' could be found (are you missing a using directive or an assembly reference?)
I have looked at every online example I can find but cannot figure out what am I missing here.
private void setTimeEstimates(ref List<Object> rides, string orig)
{
string dest, googleURL;
dynamic googleResults;
int driveTime; //in seconds
using (myEntities = new RamRideOpsEntities())
{
foreach (Ride ride in rides)
{
dest = interpretAddress(ride.PickupAddress);
googleURL = "http://maps.googleapis.com/maps/api/distancematrix/json" +
"?origins=" + orig +
"&destinations=" + dest +
"&mode=driving&sensor=false";
googleResults = new Uri(googleURL).GetDynamicJsonObject(); //EXCEPTION HERE!
driveTime = googleResults.result.duration;
ride.EstTime = driveTime + BASE_WAIT_TIME;
}
myEntities.SaveChanges();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简单修复:忘记添加 JsonUtils 扩展方法
Easy fix: forgot to add JsonUtils extension methods