IObservable 不包含定义,但实际上有定义在那里

IObservable doesnt Contain the defintion, but actualy there is the definition in there

我尝试通过 Akavache 加载缓存数据,但我不知道为什么我无法正确加载。我尝试获取我在登录后缓存的全名和电子邮件,所以我在我的 "CachedUser" 模型中获取了对象,但不知道为什么它说那里没有全名和电子邮件的定义。 这是我的 CachedUser 模型

namespace KGVC.Models
{
    public class CachedUsers
    {
        public string FullName { get; set; }
        public string Email { get; set; }
    }
}

这是我尝试在 Akavache 中实现的 getobject 代码

   public void GetDataCache(object sender, EventArgs e)
        {
            var loaded =  BlobCache.LocalMachine.GetObject<CachedUsers>("usercached");

            txtemail.Text = loaded.FullName;
            txtfullname.Text = loaded.FullName.ToString();
        }

这里是缓存用户代码

 public  void CacheUser(AuthenticationResult ar)
        {
            JObject user = ParseIdToken(ar.IdToken);
            var cache = new CachedUsers
            {
                FullName = user["name"]?.ToString(),
                Email = user["emails"]?.ToString()

            };
             BlobCache.LocalMachine.InsertObject("usercached", cache);

        }

这是我收到的完整错误消息

'IObservable<CachedUsers>' does not contain a definition for 'FullName' and no extension method 'FullName' accepting a first argument of type 'IObservable<CachedUsers>' could be found (are you missing a using directive or an assembly reference?)

这里有什么问题,因为我认为我的代码没有任何问题。你能解决这个问题吗?

你要么等待它

 public async void GetDataCache(object sender, EventArgs e)
 {
    var loaded = await BlobCache.LocalMachine.GetObject<CachedUsers>("usercached");

    txtemail.Text = loaded.FullName;
    txtfullname.Text = loaded.FullName.ToString();
 }

或订阅IObservable:

 public async void GetDataCache(object sender, EventArgs e)
 {
    var loaded = await BlobCache.LocalMachine.GetObject<CachedUsers>("usercached").Subscribe(user => {
        // TODO might need to wrap this in a Device.BeginInvokeOnMainThread
        txtemail.Text = user.FullName;
        txtfullname.Text = user.FullName.ToString();
    });
 }

查看 async/await 和 IObservable 对象的概念,以更好地理解这些概念以及此特定案例中的问题所在。