using System;
using System.Collections.Generic;
using Toolbox.Docking.Api.Control;
using Toolbox.Docking.Api.Objects;
using Toolbox.Docking.Api.Objects.Metabolism;

namespace ToolboxAddinExamples.Metabolilsm
{
    public class MetabolismAddinFactory : ITbMetabolismFactory
    {
        public MetabolismAddinFactory()
        {
            //The MUST preliminary initialize properties of IObjectFactory
            Flags = TbObjectFlags.WorkWithMixtures;
            ObjectId = new TbObjectId("(Test) ONS-Carbons", Guid.Parse("93006dec-6fa2-456d-8cde-3bb291ca3a5c"), new Version(1, 0));
            MetabolismType = MetabolismFlags.Simulated;
            ProductName = "metabolite";
            ObjectAbout = new TbObjectAbout(
                "A test metabolism stimulator which is an example of how to use the Toolbox API for metabolites."
                + " The metabolism produces products by the following algorithm: " +
                "\nIf SMILES contains \"O\" produce x metabolites OC<1-x>, where x=count of \"O\" in SMILES" +
                "\nIf SMILES contains \"N\" produce y metabolites NC<1-y>, where y=count of \"N\" in SMILES" +
                "\nIf SMILES contains \"S\" produce z metabolites NC<1-z>, where z=count of \"S\" in SMILES.",
                "LMC", null, "LMC", null, ObjectId.Caption,
                //TODO: toolbox object documentation file?
                null,
                null);
        }

        public bool InitFactory(IList<string> errorLog, ITbInitTask initTask)
        {
            return true;
        }

        public TbObjectFlags Flags { get; }

        public TbObjectId ObjectId { get; }

        public TbObjectAbout ObjectAbout { get; }

        public MetabolismFlags MetabolismType { get; }
        public string ProductName { get; }

        public ITbMetabolism GetMetabolism(ITbWorkTask task)
        {
            return new MetabolismAddin();
        }
    }
}
