/// <summary> /// Remove a given surveyed surface from a site model /// </summary> /// <param name="SiteModelID"></param> /// <param name="SurveySurfaceID"></param> /// <returns></returns> public bool RemoveDirect(Guid SiteModelID, Guid SurveySurfaceID) { // TODO: This should be done under a lock on the cache key. For now, we will live with the race condition try { INonSpatialAffinityKey cacheKey = CacheKey(SiteModelID); // Get the surveyed surfaces, creating it if it does not exist ISurveyedSurfaces ssList = DIContext.Obtain <ISurveyedSurfaces>(); ssList.FromBytes(mutableNonSpatialCache.Get(cacheKey)); // Add the new surveyed surface, generating a random ID from a GUID bool result = ssList.RemoveSurveyedSurface(SurveySurfaceID); // Put the list back into the cache with the new entry if (result) { mutableNonSpatialCache.Put(cacheKey, ssList.ToBytes()); } return(result); } catch (KeyNotFoundException) { return(false); } }
public bool Process(IMutableCacheEntry <INonSpatialAffinityKey, byte[]> entry, Guid arg) { ISurveyedSurfaces ss = DIContext.Obtain <ISurveyedSurfaces>(); if (entry.Exists) { ss.FromBytes(entry.Value); } if (ss.RemoveSurveyedSurface(arg)) { entry.Value = ss.ToBytes(); return(true); } return(false); }