Пример #1
0
 /// <summary>
 /// Returns session object with given id. If it doesn't exist,
 /// it's created.
 /// </summary>
 /// <param name="sessionObjectId"></param>
 /// <returns></returns>
 public SessionObject GetOrCreate(int sessionObjectId)
 {
     lock (_objects)
     {
         if (!_objects.TryGetValue(sessionObjectId, out var obj))
         {
             obj = new SessionObject(sessionObjectId);
         }
         return(obj);
     }
 }
Пример #2
0
 /// <summary>
 /// Adds given session object to collection.
 /// </summary>
 /// <param name="obj"></param>
 public void Add(SessionObject obj)
 {
     lock (_objects)
         _objects[obj.Id] = obj;
 }