using System;
using System.Collections.Generic;
using System.Text;
namespace System.Data.Linq.SqlClient {
    /// 
    /// Associate annotations with SqlNodes.
    /// 
    internal class SqlNodeAnnotations {
        Dictionary> annotationMap = new Dictionary>();
        Dictionary uniqueTypes = new Dictionary();
        /// 
        /// Add an annotation to the given node.
        /// 
        internal void Add(SqlNode node, SqlNodeAnnotation annotation) {
            List list = null;
            
            if (!this.annotationMap.TryGetValue(node, out list)) {
                list = new List();
                this.annotationMap[node]=list;
            }
            uniqueTypes[annotation.GetType()] = String.Empty;
            list.Add(annotation);
        }
        /// 
        /// Gets the annotations for the given node. Null if none.
        /// 
        internal List Get(SqlNode node) {
            List list = null;
            this.annotationMap.TryGetValue(node, out list);
            return list;
        }
        /// 
        /// Whether the given node has annotations.
        /// 
        internal bool NodeIsAnnotated(SqlNode node) {
            if (node == null)
                return false;
            return this.annotationMap.ContainsKey(node);
        }
        /// 
        /// Checks whether there's at least one annotation of the given type.
        /// 
        internal bool HasAnnotationType(Type type) {
            return this.uniqueTypes.ContainsKey(type);
        }
    }
}