/* ==============================================================================
 * 功能描述：Document  
 * 创 建 者：Garrett
 * 创建日期：2019/12/17 16:18:00
 * ==============================================================================*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestCad.Model
{
    /// <summary>
    /// Document
    /// </summary>
    class Document
    {
        private Document()
        {
            m_Objects = new List<CADObject>();
            Elements =new Dictionary<string, List<CADObject>>();
        }

        public static Document CreateDocument()
        {
            return new Document();
        }

        private List<CADObject> m_Objects;
        public Dictionary<string, List<CADObject>> Elements { get; private set; }

        public void AddObject(CADObject cadObject)
        {
            m_Objects.Add(cadObject);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="document"></param>
        public void GroupElements()
        {
            var group = m_Objects.GroupBy(bim => bim.GetType().Name);
            var dic = new Dictionary<string, List<CADObject>>();
            foreach (var collection in group)
            {
                dic[collection.Key + "s"] = collection.ToList();
            }
            Elements = dic;
        }
    }
}
