/// <summary> /// Invokes the <see cref="ValueLoader"/>. /// </summary> public void Load() { if (ValueLoader != null) { Value = ValueLoader.Invoke(Key); } }
/// <summary> /// Updates the object value from a source object of the same type. /// </summary> /// <param name="loader"></param> /// <param name="source"></param> private void UpdateFrom(ValueLoader loader, object source) { Version++; // if no one is holding the value, don't bother updating. // if (!CheckIfAnyoneCares()) { return; } int version = Version; object value = ValueInternal; // sure source matches dest // if (!value.GetType().IsInstanceOfType(source)) { throw new InvalidOperationException("Types not compatible"); } Action handler = () => { // make sure another update hasn't beat us to the punch. if (Version > version) { return; } try { _stats.OnStartUpdate(); ReflectionSerializer.UpdateObject(source, value, true, LastUpdatedTime); } finally { _stats.OnCompleteUpdate(); } // notify successful completion. NotifyCompletion(loader, null); }; if (SynchronousMode) { handler(); } else { PriorityQueue.AddUiWorkItem( handler ); } }
/// <summary> /// Start loading operation /// </summary> /// <param name="force">indicates if loading should be forced</param> /// <param name="loader">loader that should be invoked</param> private void StartLoading(bool force, ValueLoader loader) { NextCompletedAction.RegisterActiveLoader(loader.LoaderType); try { loader.FetchData(force); } catch (Exception) { NextCompletedAction.UnregisterLoader(loader.LoaderType); throw; } }
/// <summary> /// Invokes the <see cref="ValueLoader"/>. /// </summary> public void Load(bool force = false) { if (ValueLoader != null) { if (force) { value = ValueLoader.Invoke(Key, DefaultValue); } else { Value = ValueLoader.Invoke(Key, DefaultValue); } } }
/// <summary> /// Notify any listeners of completion of the load, or of any exceptions /// that occurred during loading. /// </summary> /// <param name="loader"></param> /// <param name="ex"></param> private void NotifyCompletion(ValueLoader loader, Exception ex) { IUpdatable iupd = ValueInternal as IUpdatable; if (iupd != null) { iupd.IsUpdating = false; } ModelItemBase mib = ValueInternal as ModelItemBase; if (mib != null) { try { mib.OnLoadCompleted(ex, false); } catch (Exception) { } } LoaderType loaderType = loader != null ? loader.LoaderType : LoaderType.CacheLoader; // UpdateCompletionHandler makes sure to call handler on UI thread // try { if (ex == null) { NextCompletedAction.OnSuccess(loaderType); if (_proxyComplitionCallback != null) { _proxyComplitionCallback(this); } } else { NextCompletedAction.OnError(loaderType, ex); } } finally { // free our value root // _rootedValue = null; } }
/// <summary> /// Callback that fires when the LiveValueLoader has completed it's load and is handing /// us a new value. /// </summary> void Live_ValueAvailable(object sender, ValueAvailableEventArgs e) { // is this the same value we already have? // if (e.UpdateTime == LastUpdatedTime) { return; } // update update and expiration times. // var value = e.Value; ValueLoader loader = (ValueLoader)sender; UpdateExpiration(e.UpdateTime, value as ICachedItem); if (value != null) { UpdateFrom(loader, value); } else { // not clear what to do with null values. // NotifyCompletion(loader, null); return; } HaveWeEverGottenALiveValue = true; // We are no longer using the cached value. // SetBoolValue(UsingCachedValueMask, false); // as long as this thing isn't NoCache, write // it to the store. // if (CachePolicy != AgFx.CachePolicy.NoCache) { SerializeDataToCache(value, _liveLoader.UpdateTime, _valueExpirationTime, false); } }
public CorValRef(ValueLoader loader) { this.val = loader(); this.loader = loader; this.version = CorDebuggerSession.EvaluationTimestamp; }
public CorValRef (ValueLoader loader) { this.val = loader (); this.loader = loader; this.version = CorDebuggerSession.EvaluationTimestamp; }
public CorValRef(ValueLoader loader) : base(loader) { }
public CorValRef(CorDebugValue val, ValueLoader loader) { this.val = val; this.loader = loader; this.version = MicroFrameworkDebuggerSession.EvaluationTimestamp; }
/// <summary> /// Start loading operation /// </summary> /// <param name="force">indicates if loading should be forced</param> /// <param name="loader">loader that should be invoked</param> private void StartLoading(bool force, ValueLoader loader) { NextCompletedAction.RegisterActiveLoader(loader.LoaderType); try { loader.FetchData(force); } catch (Exception) { NextCompletedAction.UnregisterLoader(loader.LoaderType); throw; } }
/// <summary> /// Notify any listeners of completion of the load, or of any exceptions /// that occurred during loading. /// </summary> /// <param name="loader"></param> /// <param name="ex"></param> private void NotifyCompletion(ValueLoader loader, Exception ex) { IUpdatable iupd = ValueInternal as IUpdatable; if (iupd != null) { iupd.IsUpdating = false; } LoaderType loaderType = loader != null ? loader.LoaderType : LoaderType.CacheLoader; // UpdateCompletionHandler makes sure to call handler on UI thread // try { if (ex == null) { NextCompletedAction.OnSuccess(loaderType); if (_proxyComplitionCallback != null) { _proxyComplitionCallback(this); } } else { NextCompletedAction.OnError(loaderType, ex); } } finally { // free our value root // _rootedValue = null; } }
public CorValRef(CorApi.Portable.Value val, ValueLoader loader) : base(val, loader) { }
public void IsIntegerTest_StringInput_Empty() { Assert.IsFalse(ValueLoader.IsInteger("")); }
public void IsIntegerTest_StringInput() { Assert.IsFalse(ValueLoader.IsInteger("This is some random string")); }
public void IsIntegerTest_IntegerInput() { Assert.IsTrue(ValueLoader.IsInteger("1")); }
/// <summary> /// Updates the object value from a source object of the same type. /// </summary> /// <param name="loader"></param> /// <param name="source"></param> private void UpdateFrom(ValueLoader loader, object source) { Version++; // if no one is holding the value, don't bother updating. // if (!CheckIfAnyoneCares()) { return; } int version = Version; object value = ValueInternal; // sure source matches dest // if (!value.GetType().IsInstanceOfType(source)) { throw new InvalidOperationException("Types not compatible"); } Action handler = () => { // make sure another update hasn't beat us to the punch. if (Version > version) { return; } try { _stats.OnStartUpdate(); ReflectionSerializer.UpdateObject(source, value, true, LastUpdatedTime); } finally { _stats.OnCompleteUpdate(); } // notify successful completion. NotifyCompletion(loader, null); }; if (SynchronousMode) { handler(); } else { PriorityQueue.AddUiWorkItem( handler ); } }
public CorValRef(CorValue val, ValueLoader loader) : base(val, loader) { }
private int LoadValues(object[] values, ValueLoader getValue) { CheckHaveRow(); // Only the number of elements in the array are filled. // It's also possible to pass an array with more that FieldCount elements. Int32 maxColumnIndex = (values.Length < FieldCount) ? values.Length : FieldCount; for (Int32 i = 0; i < maxColumnIndex; i++) { values[i] = getValue(i); } return maxColumnIndex; }
public CorValRef (CorDebugValue val, ValueLoader loader) { this.val = val; this.loader = loader; this.version = MicroFrameworkDebuggerSession.EvaluationTimestamp; }