private readonly static object _syncLock = new object();                                        // Synchronization object for multiple threads.
        #endregion

        #region Properties.
        /// <summary>
        /// Property to set or return a dependency by name.
        /// </summary>
        /// <remarks>Setting a dependency to NULL (Nothing in VB.Net) will remove it from the collection.</remarks>
        public Dependency this[EditorFile file, string type]
        {
            get
            {
                return(_dependencies[new DependencyKey(file, type)]);
            }
            internal set
            {
                var  key     = new DependencyKey(file, type);
                bool hasItem = _dependencies.ContainsKey(key);

                if (value == null)
                {
                    if (hasItem)
                    {
                        _dependencies.Remove(key);
                    }

                    return;
                }

                if ((hasItem) && ((file != value.EditorFile) ||
                                  (!string.Equals(type, value.Type, StringComparison.OrdinalIgnoreCase))))
                {
                    _dependencies.Remove(key);
                }

                _dependencies[key] = value;
            }
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var result = (targetType != null ? targetType.GetHashCode() : 0);
         result = (result * 397) ^ (DependencyKey != null ? DependencyKey.GetHashCode() : 0);
         return(result);
     }
 }
        /// <summary>
        /// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1" />.
        /// </summary>
        /// <param name="item">The object to add to the <see cref="T:System.Collections.Generic.ICollection`1" />.</param>
        /// <exception cref="System.ArgumentNullException">item</exception>
        /// <exception cref="System.ArgumentException"></exception>
        void ICollection <Dependency> .Add(Dependency item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            var key = new DependencyKey(item);

            if (Contains(item.EditorFile, key.Type))
            {
                throw new ArgumentException(string.Format(APIResources.GOREDIT_ERR_DEPENDENCY_EXISTS, key.Type, key.File.FilePath));
            }

            _dependencies[key] = item;
        }