using Android.App;
using Android.Content;
using Android.OS;
using FabAccessAPI;

namespace Borepin.Droid.Services
{
    [Service(Name= "org.fab_infra.fabaccess.APIService")]
    public class APIBindedService : Android.App.Service
    {
        #region Private Members
        private IAPI _API;
        #endregion

        #region Members
        public IBinder Binder { get; private set; }
        #endregion

        #region Methods
        public IAPI GetAPI()
        {
            return _API;
        }

        public override void OnCreate()
        {
            base.OnCreate();
            _API = new API();
        }

        public override IBinder OnBind(Intent intent)
        {
            Binder = new APIBinder(this);
            return Binder;
        }

        public override bool OnUnbind(Intent intent)
        {
            return base.OnUnbind(intent);
        }

        public override void OnDestroy()
        {
            Binder = null;
            _API = null;
            base.OnDestroy();
        }
        #endregion
    }
}