using StubCore.Entities;
using StubCore.Configuration;
using StubCore.Plugins.DataCollector;

namespace StubAP.Plugins.ReferenceData
{
    public class ReferenceOperations
    {     
        private readonly string _folder;
        private readonly string _extension;

        private ReferenceCollector _data;

        public ReferenceOperations()
        {
            _folder = "Options";
            _extension = "." + Configuration.DataType;
        }

        internal void InitCollector(string source)
        {
            _data = new ReferenceCollector(ConfigManager.GetOptions(source) + _extension, _folder);
        }

        public string DefineValueByID(string source, int id)
        {
            InitCollector(source);
            var option = _data.GetItem<Option>(id);
            return option.value;
        }

        public string DefineCodeByID(string source, int id)
        {
            InitCollector(source);
            var option = _data.GetItem<Option>(id);
            return option.code;
        }

        public Option DefineOptionByID(string source, int id)
        {
            InitCollector(source);
            return _data.GetItem<Option>(id);
            
        }

        public int DefineIDByOption(string source, string option)
        {
            return 0;
        }

    }
}