예제 #1
0
 public DBEventType this[string name] {
     get {
         if (String.IsNullOrWhiteSpace(name))
         {
             return(null);
         }
         name = name.ToAlphaNumericLower();
         Helpers.BlockUntilFinished(ref _initTask);
         if (_byName.TryGetValue(name, out var cached))
         {
             return(cached.Item);
         }
         DateTime lastMiss = _nameMisses.GetValueOrDefault(name);
         if (lastMiss < DateTime.Now.AddSeconds(-MissExpireSecs))
         {
             using (var cmd = DBEventType.GetSqlCommandForSP_GetOne(Ctx, null, name)) {
                 CachedEntry tag = AddTag(cmd.ExecuteReader_GetOne <DBEventType>());
                 if (tag != null)
                 {
                     return(tag.Item);
                 }
             }
             _nameMisses[name] = DateTime.Now;
         }
         return(null);
     }
 }
예제 #2
0
 public DBEventType this[long id] {
     get {
         if (id <= 0)
         {
             return(null);
         }
         Helpers.BlockUntilFinished(ref _initTask);
         if (_byId.TryGetValue(id, out var cached))
         {
             return(cached.Item);
         }
         DateTime lastMiss = _idMisses.GetValueOrDefault(id);
         if (lastMiss < DateTime.Now.AddSeconds(-MissExpireSecs))
         {
             using (var cmd = DBEventType.GetSqlCommandForSP_GetOne(Ctx, id)) {
                 CachedEntry tag = AddTag(cmd.ExecuteReader_GetOne <DBEventType>());
                 if (tag != null)
                 {
                     return(tag.Item);
                 }
             }
             _idMisses[id] = DateTime.Now;
         }
         return(null);
     }
 }