private void UpdateData( ) { try { if (StoreRef == null) { State = LazyState.Initialised; Storage = null; return; } if (dataState != null) { Storage = dataState.IO.GetID <T> (StoreRef); //Console.WriteLine ( "Updated Lazy Ref " + " for " + Storage.ToString ( ) ); State = LazyState.UpToDate; } } catch (Exception ex) { State = LazyState.NotInitialised; error = ex; ChampionshipSolutions.Diag.Diagnostics.LogLine("Lazy loading error of type " + typeof(T).ToString( )); ChampionshipSolutions.Diag.Diagnostics.LogLine(ex.Message); } }
public LazyStateTest() { _address = new Address("66eD03107F270d082AC1F71d8E50375f9372d8fC"); _state = new SampleState(_address, 123L, "hello"); _serializedEncoding = (Dictionary)_state.Serialize(); _loaded = new LazySampleState(_state); _unloaded = new LazySampleState(_serializedEncoding, d => new SampleState(d)); }
public LazyRefN(DataState ds, Func <int?> getter, Action <int?> setter) : this() { dataState = ds; this.getter = getter; this.setter = setter; if (dataState != null) { State = LazyState.Initialised; } }
private void UpdateData( ) { try { List = dataState.IO.GetAll <T> ( ).Where(pre).ToList( ); //Console.WriteLine ( "Updated Lazy List " + typeof ( T ).Name.ToString ( ) + " for " + pre.Target.ToString ( ) ); State = LazyState.UpToDate; } catch (Exception ex) { State = LazyState.NotInitialised; error = ex; ChampionshipSolutions.Diag.Diagnostics.LogLine("Lazy loading error of type " + typeof(T).ToString( )); ChampionshipSolutions.Diag.Diagnostics.LogLine(ex.Message); } }
internal static LazyHelper Create(LazyThreadSafetyMode mode, bool useDefaultConstructor) { switch (mode) { case LazyThreadSafetyMode.None: return(useDefaultConstructor ? NoneViaConstructor : NoneViaFactory); case LazyThreadSafetyMode.PublicationOnly: return(useDefaultConstructor ? PublicationOnlyViaConstructor : PublicationOnlyViaFactory); case LazyThreadSafetyMode.ExecutionAndPublication: // we need to create an object for ExecutionAndPublication because we use Monitor-based locking LazyState state = useDefaultConstructor ? LazyState.ExecutionAndPublicationViaConstructor : LazyState.ExecutionAndPublicationViaFactory; return(new LazyHelper(state)); default: throw new ArgumentOutOfRangeException(nameof(mode), SR.Lazy_ctor_ModeInvalid); } }
internal LazyHelper(LazyThreadSafetyMode mode, Exception exception) { switch (mode) { case LazyThreadSafetyMode.ExecutionAndPublication: State = LazyState.ExecutionAndPublicationException; break; case LazyThreadSafetyMode.None: State = LazyState.NoneException; break; case LazyThreadSafetyMode.PublicationOnly: State = LazyState.PublicationOnlyException; break; default: break; } _exceptionDispatch = ExceptionDispatchInfo.Capture(exception); }
/// <summary> /// Constructor used for exceptions /// </summary> internal LazyHelper(LazyThreadSafetyMode mode, Exception exception) { switch (mode) { case LazyThreadSafetyMode.ExecutionAndPublication: State = LazyState.ExecutionAndPublicationException; break; case LazyThreadSafetyMode.None: State = LazyState.NoneException; break; case LazyThreadSafetyMode.PublicationOnly: State = LazyState.PublicationOnlyException; break; default: Debug.Assert(false, "internal constructor, this should never occur"); break; } _exceptionDispatch = ExceptionDispatchInfo.Capture(exception); }
/// <summary> /// Constructor that defines the state /// </summary> internal LazyHelper(LazyState state) { State = state; }
public void refresh( ) { State = LazyState.NeedsUpdating; }
public LazyRefN( ) { State = LazyState.NotInitialised; }
public LazyList(DataState ds, Func <T, bool> predicate) { dataState = ds; pre = predicate; State = LazyState.Initialised; }
public LazyList( ) { State = LazyState.NotInitialised; }