コード例 #1
0
        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);
            }
        }
コード例 #2
0
 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));
 }
コード例 #3
0
 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;
     }
 }
コード例 #4
0
 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);
     }
 }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
ファイル: Lazy.cs プロジェクト: qkb/Norns.Urd
        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);
        }
コード例 #7
0
ファイル: Lazy.cs プロジェクト: wecing/coreclr
        /// <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);
        }
コード例 #8
0
ファイル: Lazy.cs プロジェクト: wecing/coreclr
 /// <summary>
 /// Constructor that defines the state
 /// </summary>
 internal LazyHelper(LazyState state)
 {
     State = state;
 }
コード例 #9
0
 public void refresh( )
 {
     State = LazyState.NeedsUpdating;
 }
コード例 #10
0
 public LazyRefN( )
 {
     State = LazyState.NotInitialised;
 }
コード例 #11
0
 public LazyList(DataState ds, Func <T, bool> predicate)
 {
     dataState = ds;
     pre       = predicate;
     State     = LazyState.Initialised;
 }
コード例 #12
0
 public LazyList( )
 {
     State = LazyState.NotInitialised;
 }