/// <inheritdoc/> /// <summary> /// See <see cref="IContextObject.Retrieve{T}()"/> /// </summary> public T Retrieve <T>() { if (TypedStorage.TryGetValue(typeof(T), out object value)) { return((T)value); } return(default(T)); }
/// <inheritdoc/> /// <summary> /// See <see cref="IContextObject.TryRetrieve{T}(out T)"/> /// </summary> /// <typeparam name="T"></typeparam> /// <param name="value"></param> /// <returns></returns> public bool TryRetrieve <T>(out T value) { if (TypedStorage.TryGetValue(typeof(T), out object val)) { value = (T)val; return(true); } value = default(T); return(false); }
private void OnDownloadStringCompleted(object sender, DownloadEventArg e) { if (!e.Success) { Dispatcher.BeginInvoke( () => MessageBox.Show("������������ ����� ��� ������", "������ �����������", MessageBoxButton.OK)); //((PhoneApplicationFrame)Application.Current.RootVisual).GoBack(); return; } var token = JsonConvert.DeserializeObject<AccessToken>(e.Result); ITypedDataStorage<AccessToken> storage = new TypedStorage<AccessToken>(); storage.SaveEntity(token); }
/// <inheritdoc/> /// <summary> /// See <see cref="IContextObject.Store{T}(object)"/> /// </summary> public void Store <T>(object obj) { //Replace the old object with the new if an old object exists, or add a new object TypedStorage.AddOrUpdate(typeof(T), obj, (type, existing) => obj); }