从 2.7 迁移到 2.8
在本迁移指南中,我们将介绍 2.8 中已删除/更改的 API,以及应该使用的替代方案。
更新的 API
Cookie 存储
v2.7 之前,在设置 cookie 时需要传递网页 URL:
Cookie cookie = new Cookie.Builder
{
Name = "name",
Value = "value",
DomainName = ".google.com",
Path = "/"
}.Build();
bool success =
engine.Profiles.Default.CookieStore.SetCookie("https://www.google.com",cookie).Result;
engine.Profiles.Default.CookieStore.Flush();
Dim cookie As Cookie = New Cookie.Builder With {
.Name = "name",
.Value = "value",
.DomainName = ".google.com",
.Path = "/"
}.Build()
Dim success As Boolean =
engine.Profiles.Default.CookieStore.SetCookie("https://www.google.com",cookie).Result
engine.Profiles.Default.CookieStore.Flush()
v2.8
ICookieStore.SetCookie()
现在没有 URL 参数,因为之前它仅用于验证目的:
Cookie cookie = new Cookie.Builder(".google.com")
{
Name = "name",
Value = "value",
Path = "/"
}.Build();
bool success = engine.Profiles.Default.CookieStore.SetCookie(cookie).Result;
engine.Profiles.Default.CookieStore.Flush();
Dim cookie As Cookie = New Cookie.Builder(".google.com") With {
.Name = "name",
.Value = "value",
.Path = "/"
}.Build()
Dim success As Boolean = engine.Profiles.Default.CookieStore.SetCookie(cookie).Result
engine.Profiles.Default.CookieStore.Flush()
现在需要指定域名。 此外, ICookieStore.Delete()
现在返回 Task
,而不是 Task<bool>
。