object IBuildEngine4.UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime)
        {
            var obj = Tasks [key];

            Tasks.Remove(key);
            return(obj);
        }
Ejemplo n.º 2
0
        public object GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime)
        {
            object obj = null;

            _objectCashe.TryGetValue(key, out obj);
            return(obj);
        }
Ejemplo n.º 3
0
        public object UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime)
        {
            var obj = _objectCashe[key];

            _objectCashe.Remove(key);
            return(obj);
        }
Ejemplo n.º 4
0
 public TaskObjectRegistration(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection)
 {
     Key                  = key;
     Object               = obj;
     Lifetime             = lifetime;
     AllowEarlyCollection = allowEarlyCollection;
 }
Ejemplo n.º 5
0
            public object GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime)
            {
                RegisteredTaskObjectsQueries++;

                RegisteredTaskObjects.TryGetValue(key, out object ret);
                return(ret);
            }
Ejemplo n.º 6
0
        object IBuildEngine4.GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime)
        {
            object obj = null;

            Tasks.TryGetValue(key, out obj);
            return(obj);
        }
Ejemplo n.º 7
0
 object IBuildEngine4.UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime)
 {
     if (Tasks.TryGetValue(key, out object value))
     {
         Tasks.Remove(key);
     }
     return(value);
 }
Ejemplo n.º 8
0
        /// <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);
            }
        }
Ejemplo n.º 9
0
        /// <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);
            }
        }
Ejemplo n.º 11
0
        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;
        }
Ejemplo n.º 13
0
        /// <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);
        }
Ejemplo n.º 14
0
 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);
 }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
0
        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);
            }
        }
Ejemplo n.º 17
0
 public object GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime)
 {
     object obj = null;
     _objectCashe.TryGetValue(key, out obj);
     return obj;
 }
Ejemplo n.º 18
0
 private IDictionary <object, object> GetCache(RegisteredTaskObjectLifetime lifetime) =>
 lifetime == RegisteredTaskObjectLifetime.Build ? _objectCacheLivingUntilBuild : _objectCacheLivingInAppDomain;
Ejemplo n.º 19
0
 object IBuildEngine4.GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime)
 {
     Tasks.TryGetValue(key, out object value);
     return(value);
 }
Ejemplo n.º 20
0
 public object GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 21
0
 public object GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime) =>
 GetCache(lifetime).TryGetValue(key, out var value) ? value : null;
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 23
0
 /// <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;
        }
Ejemplo n.º 26
0
		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;
		}
Ejemplo n.º 27
0
        /// <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));
        }
Ejemplo n.º 28
0
		public void RegisterTaskObject (object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection)
		{
			task_objects.Add (new TaskObjectRegistration (key, obj, lifetime, allowEarlyCollection));
		}
Ejemplo n.º 29
0
		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;
		}
Ejemplo n.º 30
0
			public TaskObjectRegistration (object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection)
			{
				Key = key;
				Object = obj;
				Lifetime = lifetime;
				AllowEarlyCollection = allowEarlyCollection;
			}
Ejemplo n.º 31
0
 public object UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime)
 {
     var obj = _objectCashe[key];
     _objectCashe.Remove(key);
     return obj;
 }
Ejemplo n.º 32
0
 public void RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection)
 {
     _objectCashe[key] = obj;
 }
Ejemplo n.º 33
0
 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;
        }
Ejemplo n.º 36
0
        /// <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);
        }
Ejemplo n.º 37
0
 public void RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection)
 {
     task_objects.Add(new TaskObjectRegistration(key, obj, lifetime, allowEarlyCollection));
 }
Ejemplo n.º 38
0
 public object UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime)
 {
     return null;
 }
Ejemplo n.º 39
0
 public void RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 40
0
 /// <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);
 }
Ejemplo n.º 41
0
 /// <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);
 }
Ejemplo n.º 42
0
 /// <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);
 }
Ejemplo n.º 43
0
 public object UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime) =>
 GetCache(lifetime).TryRemove(key, out var value) ? value : null;
Ejemplo n.º 44
0
        /// <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);
        }
Ejemplo n.º 45
0
 void IBuildEngine4.RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection)
 {
     Tasks [key] = obj;
 }
Ejemplo n.º 46
0
        /// <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));
        }
Ejemplo n.º 47
0
        /// <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);
 }