using System;
using System.Collections;
using System.Collections.Generic;
using MarketData.Utils;
using MarketData.DataAccess;

namespace MarketData.Utils
{
  public class HolidayCache
  {
    private static HolidayCache instance=null;
    private Dictionary<DateTime,DateTime> holidays=null;

    private HolidayCache()
    {
      holidays=HolidayDA.GetHolidays();
    }
    public static HolidayCache GetInstance()
    {
      lock(typeof(HolidayCache))
      {
        if(null==instance) instance=new HolidayCache();
        return instance;
      }
    }
    public bool IsHoliday(DateTime dateTime)
    {
      lock(instance)
      {
        if(null==holidays) return false;
        return holidays.ContainsKey(dateTime.Date);
      }
    }
  }
}
