コード例 #1
0
ファイル: AircraftFetcher.cs プロジェクト: vishalishere/vrs
        /// <summary>
        /// Registers or refreshes the entry for the key passed across.
        /// </summary>
        /// <param name="key">The key to register. This must be usable within a dictionary.</param>
        /// <param name="aircraft">The aircraft to associate with the key, if any. Pass null if the aircraft is unknown.</param>
        /// <returns></returns>
        protected virtual TDetail DoRegisterAircraft(TKey key, IAircraft aircraft)
        {
            TDetail result = null;

            Initialise();

            lock (_QueueLock) {
                FetchedDetail fetchedDetail;
                if (!_FetchedDetailMap.TryGetValue(key, out fetchedDetail))
                {
                    if (!_LookupQueue.TryGetValue(key, out fetchedDetail))
                    {
                        fetchedDetail = new FetchedDetail()
                        {
                            Aircraft = aircraft,
                            Key      = key,
                        };
                        _LookupQueue.Add(key, fetchedDetail);
                    }
                }
                fetchedDetail.LastRegisteredUtc = _Clock.UtcNow;
                result = fetchedDetail.Detail;
            }

            return(result);
        }
コード例 #2
0
ファイル: AircraftFetcher.cs プロジェクト: vishalishere/vrs
 /// <summary>
 /// Fetches the aircraft's details.
 /// </summary>
 /// <param name="fetchedDetail"></param>
 private void FetchAircraft(FetchedDetail fetchedDetail)
 {
     lock (_FetchLock) {
         var isFirstFetch = fetchedDetail.LastCheckedUtc == default(DateTime);
         fetchedDetail.LastCheckedUtc = _Clock.UtcNow;
         fetchedDetail.Detail         = DoFetchAircraft(fetchedDetail);
     }
 }
コード例 #3
0
ファイル: AircraftFetcher.cs プロジェクト: vishalishere/vrs
 /// <summary>
 /// Fetches the detail for the aircraft, raising any events necessary when a change has been detected.
 /// </summary>
 /// <param name="fetchedDetail"></param>
 /// <returns></returns>
 protected abstract TDetail DoFetchAircraft(FetchedDetail fetchedDetail);