object IBuildEngine4.UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { var obj = Tasks [key]; Tasks.Remove(key); return(obj); }
public object GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { object obj = null; _objectCashe.TryGetValue(key, out obj); return(obj); }
public object UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { var obj = _objectCashe[key]; _objectCashe.Remove(key); return(obj); }
public TaskObjectRegistration(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection) { Key = key; Object = obj; Lifetime = lifetime; AllowEarlyCollection = allowEarlyCollection; }
public object GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { RegisteredTaskObjectsQueries++; RegisteredTaskObjects.TryGetValue(key, out object ret); return(ret); }
object IBuildEngine4.GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { object obj = null; Tasks.TryGetValue(key, out obj); return(obj); }
object IBuildEngine4.UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { if (Tasks.TryGetValue(key, out object value)) { Tasks.Remove(key); } return(value); }
/// <summary> /// Registers a task object with the specified key and lifetime. /// </summary> public void RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection) { ConcurrentDictionary <object, object> dict = GetCollectionForLifetime(lifetime, dontCreate: false); if (dict != null) { dict.TryAdd(key, obj); } }
/// <summary> /// Unregisters a previously registered task object. /// </summary> public object UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { ConcurrentDictionary <object, object> dict = GetCollectionForLifetime(lifetime, dontCreate: true); object obj = null; dict?.TryRemove(key, out obj); return(obj); }
/// <summary> /// Registers a task object with the specified key and lifetime. /// </summary> public void RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection) { ConcurrentDictionary<object, object> dict = GetCollectionForLifetime(lifetime, dontCreate: false); if (dict != null) { dict.TryAdd(key, obj); } }
public object UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { var reg = task_objects.FirstOrDefault(t => t.Key == key && t.Lifetime == lifetime); if (reg != null) { task_objects.Remove(reg); } return(reg.Object); }
/// <summary> /// Gets a previously registered task object. /// </summary> public object GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { ConcurrentDictionary<object, object> dict = GetCollectionForLifetime(lifetime, dontCreate: true); object obj = null; if (dict != null) { dict.TryGetValue(key, out obj); } return obj; }
/// <summary> /// Gets a previously registered task object. /// </summary> public object GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { ConcurrentDictionary <object, object> dict = GetCollectionForLifetime(lifetime, dontCreate: true); object obj = null; if (dict != null) { dict.TryGetValue(key, out obj); } return(obj); }
void IBuildEngine4.RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection) { if (key is null) { throw new ArgumentNullException("key"); } if (obj is null) { throw new ArgumentNullException("obj"); } Tasks.TryAdd(key, obj); }
/// <summary> /// Returns the collection associated with a particular lifetime. /// </summary> protected ConcurrentDictionary <object, object> GetCollectionForLifetime(RegisteredTaskObjectLifetime lifetime, bool dontCreate) { Lazy <ConcurrentDictionary <object, object> > dict = GetLazyCollectionForLifetime(lifetime); // If we aren't supposed to create it, don't force the creation. if (dontCreate && !dict.IsValueCreated) { return(null); } return(dict.Value); }
public void RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection) { var cache = GetCache(lifetime); if (cache.TryGetValue(key, out var value)) { cache[key] = obj; } else { cache.Add(key, obj); } }
public object GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { object obj = null; _objectCashe.TryGetValue(key, out obj); return obj; }
private IDictionary <object, object> GetCache(RegisteredTaskObjectLifetime lifetime) => lifetime == RegisteredTaskObjectLifetime.Build ? _objectCacheLivingUntilBuild : _objectCacheLivingInAppDomain;
object IBuildEngine4.GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { Tasks.TryGetValue(key, out object value); return(value); }
public object GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { throw new NotImplementedException(); }
public object GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime) => GetCache(lifetime).TryGetValue(key, out var value) ? value : null;
public object GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { var reg = task_objects.FirstOrDefault(t => t.Key == key && t.Lifetime == lifetime); return(reg != null ? reg.Object : null); }
/// <summary> /// Disposes of all of the objects with the specified lifetime. /// </summary> public void RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection) { var objectCache = (IRegisteredTaskObjectCache)_host.GetComponent(BuildComponentType.RegisteredTaskObjectCache); objectCache.RegisterTaskObject(key, obj, lifetime, allowEarlyCollection); }
/// <summary> /// Disposes of all of the cached objects registered with the specified lifetime. /// </summary> public void DisposeCacheObjects(RegisteredTaskObjectLifetime lifetime) { var lazyCollection = GetLazyCollectionForLifetime(lifetime); DisposeObjects(lazyCollection); }
/// <summary> /// Gets the lazy cache for the specified lifetime. /// </summary> protected Lazy<ConcurrentDictionary<object, object>> GetLazyCollectionForLifetime(RegisteredTaskObjectLifetime lifetime) { Lazy<ConcurrentDictionary<object, object>> dict = null; switch (lifetime) { case RegisteredTaskObjectLifetime.Build: dict = _buildLifetimeObjects; break; case RegisteredTaskObjectLifetime.AppDomain: dict = RegisteredTaskObjectCacheBase.s_appDomainLifetimeObjects; break; } return dict; }
public object UnregisterTaskObject (object key, RegisteredTaskObjectLifetime lifetime) { var reg = task_objects.FirstOrDefault (t => t.Key == key && t.Lifetime == lifetime); if (reg != null) task_objects.Remove (reg); return reg.Object; }
/// <summary> /// Returns true if a collection is not yet created or if it has no content. /// </summary> protected bool IsCollectionEmptyOrUncreated(RegisteredTaskObjectLifetime lifetime) { var collection = GetCollectionForLifetime(lifetime, dontCreate: true); return((collection == null) || (collection.Count == 0)); }
public void RegisterTaskObject (object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection) { task_objects.Add (new TaskObjectRegistration (key, obj, lifetime, allowEarlyCollection)); }
public object GetRegisteredTaskObject (object key, RegisteredTaskObjectLifetime lifetime) { var reg = task_objects.FirstOrDefault (t => t.Key == key && t.Lifetime == lifetime); return reg != null ? reg.Object : null; }
public TaskObjectRegistration (object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection) { Key = key; Object = obj; Lifetime = lifetime; AllowEarlyCollection = allowEarlyCollection; }
public object UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { var obj = _objectCashe[key]; _objectCashe.Remove(key); return obj; }
public void RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection) { _objectCashe[key] = obj; }
/// <summary> /// Returns true if a collection is not yet created or if it has no content. /// </summary> protected bool IsCollectionEmptyOrUncreated(RegisteredTaskObjectLifetime lifetime) { var collection = GetCollectionForLifetime(lifetime, dontCreate: true); return (collection == null) || (collection.Count == 0); }
/// <summary> /// Returns the collection associated with a particular lifetime. /// </summary> protected ConcurrentDictionary<object, object> GetCollectionForLifetime(RegisteredTaskObjectLifetime lifetime, bool dontCreate) { Lazy<ConcurrentDictionary<object, object>> dict = GetLazyCollectionForLifetime(lifetime); // If we aren't supposed to create it, don't force the creation. if (dontCreate && !dict.IsValueCreated) { return null; } return dict.Value; }
public void RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection) { task_objects.Add(new TaskObjectRegistration(key, obj, lifetime, allowEarlyCollection)); }
public object UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { return null; }
public void RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection) { throw new NotImplementedException(); }
/// <summary> /// Unregisters a task object. /// </summary> public object UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { var objectCache = (IRegisteredTaskObjectCache)_host.GetComponent(BuildComponentType.RegisteredTaskObjectCache); return objectCache.UnregisterTaskObject(key, lifetime); }
/// <summary> /// Registers an object with the system that will be disposed of at some specified time /// in the future. /// </summary> /// <param name="key">The key used to retrieve the object.</param> /// <param name="obj">The object to be held for later disposal.</param> /// <param name="lifetime">The lifetime of the object.</param> /// <param name="allowEarlyCollection">The object may be disposed earlier that the requested time if /// MSBuild needs to reclaim memory.</param> public void RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection) { _registeredTaskObjectCache.RegisterTaskObject(key, obj, lifetime, allowEarlyCollection); }
/// <summary> /// Unregisters a previously-registered task object. /// </summary> /// <param name="key">The key used to retrieve the object.</param> /// <param name="lifetime">The lifetime of the object.</param> /// <returns> /// The registered object, or null is there is no object registered under that key or the object /// has been discarded through early collection. /// </returns> public object UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { return _registeredTaskObjectCache.UnregisterTaskObject(key, lifetime); }
public object UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime) => GetCache(lifetime).TryRemove(key, out var value) ? value : null;
void IBuildEngine4.RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection) { Tasks [key] = obj; }
/// <summary> /// Unregisters a task object. /// </summary> public object UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { var objectCache = (IRegisteredTaskObjectCache)_host.GetComponent(BuildComponentType.RegisteredTaskObjectCache); return(objectCache.UnregisterTaskObject(key, lifetime)); }
/// <summary> /// Gets the lazy cache for the specified lifetime. /// </summary> protected Lazy <ConcurrentDictionary <object, object> > GetLazyCollectionForLifetime(RegisteredTaskObjectLifetime lifetime) { Lazy <ConcurrentDictionary <object, object> > dict = null; switch (lifetime) { case RegisteredTaskObjectLifetime.Build: dict = _buildLifetimeObjects; break; case RegisteredTaskObjectLifetime.AppDomain: dict = RegisteredTaskObjectCacheBase.s_appDomainLifetimeObjects; break; } return(dict); }
object IBuildEngine4.GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime) { return(null); }