protected virtual bool InternalTryGetValue(UUID key, bool checkRecursive, out IEntity obj) { IScenePresence presence; bool gotit; lock (m_presenceEntitiesLock) gotit = m_presenceEntities.TryGetValue(key, out presence); if (!gotit) { ISceneEntity presence2; lock (m_objectEntitiesLock) gotit = m_objectEntities.TryGetValue(key, out presence2); //Deal with the possibility we may have been asked for a child prim if ((!gotit) && checkRecursive) { return(TryGetChildPrimParent(key, out obj)); } else if (gotit) { obj = presence2; return(true); } } else if (gotit) { obj = presence; return(true); } obj = null; return(false); }
/// <summary> /// Retrives the SceneObjectGroup of this child /// </summary> /// <param name="childkey"></param> /// <param name="obj"></param> /// <returns></returns> public virtual bool TryGetChildPrimParent(UUID childkey, out IEntity obj) { UUID ParentKey = UUID.Zero; bool gotit; lock (m_child_2_parent_entitiesLock) gotit = m_child_2_parent_entities.TryGetValue(childkey, out ParentKey); if (gotit) { return(InternalTryGetValue(ParentKey, false, out obj)); } obj = null; return(false); }
internal EnumTypeCache RequestCacheForTypeName(string name, bool checkFiles = true) { LoadCache(); if (entriesFromRequests.TryGetValue(name, out int value)) { return(new EnumTypeCache(value, name)); } if (checkFiles) { if (entriesFromFile.TryGetValue(name, out value)) { entriesFromRequests.Add(value, name); return(new EnumTypeCache(value, name)); } if (entriesFromDeactivatedFile.TryGetValue(name, out value)) { entriesFromRequests.Add(value, name); entriesFromDeactivatedFile.Remove(value, name); return(new EnumTypeCache(value, name)); } } return(null); }
public void TryGetValueTest() { DoubleKeyDictionary <int, string, string> map = CreateDictionary(); string text; map.TryGetValue(1, out text).IsTrue(); text.AreEqualWith("Z"); map.TryGetValue("a", out text).IsTrue(); text.AreEqualWith("Z"); map.TryGetValue(10, out text).IsFalse(); text.AreEqualWith(null); map.TryGetValue("D", out text).IsFalse(); text.AreEqualWith(null); }
public void MissingItemIsNotFound() { var key1 = 5; var key2 = "key2"; var dictionary = new DoubleKeyDictionary <int, string, string>(); string resultValue = null; var result = dictionary.TryGetValue(key1, key2, out resultValue); result.Should().BeFalse(); resultValue.Should().BeNull(); }
public void AddedItemIsFound() { var key1 = 5; var key2 = "key2"; var value = "asmdpsodfgkhöglhmdfgh d"; var dictionary = new DoubleKeyDictionary <int, string, string>(); dictionary.Add(key1, key2, value); string resultValue = null; var result = dictionary.TryGetValue(key1, key2, out resultValue); result.Should().BeTrue(); resultValue.Should().BeSameAs(value); }
/// <summary> /// Registers the specified model unique identifier. /// </summary> /// <typeparam name="T">Geometry Buffer Type</typeparam> /// <param name="modelGuid">The model unique identifier.</param> /// <param name="geometry">The geometry.</param> /// <returns></returns> public IGeometryBufferModel Register <T>(Guid modelGuid, Geometry3D geometry) where T : class, IGeometryBufferModel, new() { if (geometry == null || modelGuid == Guid.Empty) { return(EmptyGeometryBufferModel.Empty); } lock (bufferDictionary) { IGeometryBufferModel container; if (bufferDictionary.TryGetValue(typeof(T), geometry.GUID, out var obj)) { if (logger.IsEnabled(LogLevel.Trace)) { logger.LogTrace("Existing buffer found, GeomoetryGUID = {}", geometry.GUID); } container = obj as IGeometryBufferModel; obj.IncRef(); } else { if (logger.IsEnabled(LogLevel.Trace)) { logger.LogTrace("Buffer not found, create new buffer. GeomoetryGUID = {}", geometry.GUID); } container = new T(); var id = geometry.GUID; obj = container as DisposeObject; obj.Disposed += (s, e) => { if (logger.IsEnabled(LogLevel.Trace)) { logger.LogTrace("Disposing Geometry Buffer. GeomoetryGUID = {}", id); } lock (bufferDictionary) { bufferDictionary.Remove(typeof(T), id); } }; container.EffectsManager = manager; container.Geometry = geometry; bufferDictionary.Add(typeof(T), geometry.GUID, obj); } return(container); } }
public MaterialVariable Register(IMaterial material, IRenderTechnique technique) { if (material == null || technique.IsNull) { return(EmptyMaterialVariable.EmptyVariable); } var guid = material.Guid; var techGuid = technique.GUID; lock (dictionary) { if (dictionary.TryGetValue(guid, techGuid, out MaterialVariable value)) { value.IncRef(); return(value); } else { var v = material.CreateMaterialVariables(effectsManager, technique); v.Initialize(); v.Disposed += (s, e) => { lock (dictionary) { dictionary.Remove(guid, techGuid); } }; dictionary.Add(guid, techGuid, v); if (IDMAX - (ushort)Count > 1000) { IDMAX = 0; foreach (var m in dictionary) { m.Value.ID = ++IDMAX; } } else { v.ID = ++IDMAX; } return(v); } } }
/// <summary> /// Registers the specified model unique identifier. /// </summary> /// <typeparam name="T">Geometry Buffer Type</typeparam> /// <param name="modelGuid">The model unique identifier.</param> /// <param name="geometry">The geometry.</param> /// <returns></returns> public IGeometryBufferModel Register <T>(Guid modelGuid, Geometry3D geometry) where T : class, IGeometryBufferModel, new() { if (geometry == null || modelGuid == Guid.Empty) { return(EmptyGeometryBufferModel.Empty); } lock (bufferDictionary) { IGeometryBufferModel container; if (bufferDictionary.TryGetValue(typeof(T), geometry.GUID, out ReferenceCountDisposeObject obj)) { #if DEBUGDETAIL Debug.WriteLine("Existing buffer found, GeomoetryGUID = " + geometry.GUID); #endif container = obj as IGeometryBufferModel; obj.IncRef(); } else { #if DEBUGDETAIL Debug.WriteLine("Buffer not found, create new buffer. GeomoetryGUID = " + geometry.GUID); #endif container = new T(); var id = geometry.GUID; obj = container as ReferenceCountDisposeObject; obj.Disposed += (s, e) => { lock (bufferDictionary) { bufferDictionary.Remove(typeof(T), id); } }; container.EffectsManager = manager; container.Geometry = geometry; bufferDictionary.Add(typeof(T), geometry.GUID, obj); } return(container); } }
public bool TryGetValue(T key, out string value) { return(entriesFromRequests.TryGetValue(key, out value)); }