public bool Has(Type pluginType, Instance instance) { var key = instance.InstanceKey(pluginType); object @object; return(_objects.TryGetValue(key, out @object)); }
public object Get(Type pluginType, Instance instance, IBuildSession session) { object result = null; int key = instance.InstanceKey(pluginType); _lock.EnterUpgradeableReadLock(); if (_objects.ContainsKey(key)) { result = _objects[key]; _lock.ExitUpgradeableReadLock(); } else { _lock.EnterWriteLock(); try { result = buildWithSession(pluginType, instance, session); _objects.Add(key, result); } finally { _lock.ExitWriteLock(); } } return result; }
public object Get(Type pluginType, Instance instance, IBuildSession session) { object result; var key = instance.InstanceKey(pluginType); _lock.EnterUpgradeableReadLock(); try { if (_objects.ContainsKey(key)) { result = _objects[key]; } else { _lock.EnterWriteLock(); try { result = buildWithSession(pluginType, instance, session); _objects.Add(key, result); } finally { _lock.ExitWriteLock(); } } } finally { _lock.ExitUpgradeableReadLock(); } return(result); }
public bool Has(Type pluginType, Instance instance) { return(_lock.Read(() => { var key = instance.InstanceKey(pluginType); return _objects.ContainsKey(key); })); }
public bool Has(Type pluginType, Instance instance) { return _lock.Read(() => { var key = instance.InstanceKey(pluginType); return _objects.ContainsKey(key); }); }
public void Set(Type pluginType, Instance instance, object value) { if (value == null) { return; } var key = instance.InstanceKey(pluginType); _objects.AddOrUpdate(key, value, (_, __) => value); }
public void Eject(Type pluginType, Instance instance) { int key = instance.InstanceKey(pluginType); _lock.MaybeWrite(() => { if (!_objects.ContainsKey(key)) return; _lock.Write(() => { var disposable = _objects[key] as IDisposable; _objects.Remove(key); disposable.SafeDispose(); }); }); }
public void Eject(Type pluginType, Instance instance) { var key = instance.InstanceKey(pluginType); _lock.MaybeWrite(() => { if (!_objects.ContainsKey(key)) { return; } _lock.Write(() => { var disposable = _objects[key] as IDisposable; _objects.Remove(key); disposable.SafeDispose(); }); }); }
public void Eject(Type pluginType, Instance instance) { // Prevent null reference exception. if (pluginType.AssemblyQualifiedName == null) { return; } var key = instance.InstanceKey(pluginType); object @object; if (_objects.TryRemove(key, out @object)) { @object.SafeDispose(); } }
public void Eject(Type pluginType, Instance instance) { // Prevent null reference exception. if (pluginType.AssemblyQualifiedName == null) return; var key = instance.InstanceKey(pluginType); _lock.MaybeWrite(() => { if (!_objects.ContainsKey(key)) return; _lock.Write(() => { var disposable = _objects[key] as IDisposable; _objects.Remove(key); disposable.SafeDispose(); }); }); }
public void Set(Type pluginType, Instance instance, object value) { if (value == null) { return; } _lock.Write(() => { var key = instance.InstanceKey(pluginType); if (_objects.ContainsKey(key)) { _objects[key] = value; } else { _objects.Add(key, value); } }); }
public object Get(Type pluginType, Instance instance, IBuildSession session) { object result; var key = instance.InstanceKey(pluginType); _lock.EnterUpgradeableReadLock(); try { if (_instances.Contains(instance)) { throw new StructureMapBuildException("Bi-directional dependency relationship detected!" + Environment.NewLine + "Check the StructureMap stacktrace below:"); } if (_objects.ContainsKey(key)) { result = _objects[key]; } else { _lock.EnterWriteLock(); try { _instances.Add(instance); result = buildWithSession(pluginType, instance, session); _objects.Add(key, result); } finally { _instances.Remove(instance); _lock.ExitWriteLock(); } } } finally { _lock.ExitUpgradeableReadLock(); } return(result); }
public object Get(Type pluginType, Instance instance, IBuildSession session) { object result; var key = instance.InstanceKey(pluginType); _lock.EnterUpgradeableReadLock(); try { if (_instances.Contains(instance)) { throw new StructureMapBuildException("Bi-directional dependency relationship detected!" + Environment.NewLine + "Check the StructureMap stacktrace below:"); } if (_objects.ContainsKey(key)) { result = _objects[key]; } else { _lock.EnterWriteLock(); try { _instances.Add(instance); result = buildWithSession(pluginType, instance, session); _objects.Add(key, result); } finally { _instances.Remove(instance); _lock.ExitWriteLock(); } } } finally { _lock.ExitUpgradeableReadLock(); } return result; }
public void Eject(Type pluginType, Instance instance) { // Prevent null reference exception. if (pluginType.AssemblyQualifiedName == null) { return; } var key = instance.InstanceKey(pluginType); _lock.MaybeWrite(() => { if (!_objects.ContainsKey(key)) { return; } _lock.Write(() => { var disposable = _objects[key] as IDisposable; _objects.Remove(key); disposable.SafeDispose(); }); }); }
public void Set(Type pluginType, Instance instance, object value) { if (value == null) return; _lock.Write(() => { int key = instance.InstanceKey(pluginType); if (_objects.ContainsKey(key)) { _objects[key] = value; } else { _objects.Add(key, value); } }); }
public object Get(Type pluginType, Instance instance, IBuildSession session) { var key = instance.InstanceKey(pluginType); return(_objects.GetOrAdd(key, _ => buildWithSession(pluginType, instance, session))); }