using LHDN.CRM.BC.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LHDN.CRM.BC.Services
{
    public abstract class ServiceBase<T> : IService<T>, IDisposable
        where T : class
    {

        #region IDisposable Support
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }

        // TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
        // ~ServiceBase() {
        //   // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
        //   Dispose(false);
        // }

        // This code added to correctly implement the disposable pattern.
        public void Dispose()
        {
            // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
            Dispose(true);
            // TODO: uncomment the following line if the finalizer is overridden above.
            // GC.SuppressFinalize(this);
        }
        #endregion

        //public virtual bool CompareByteArray(byte[] obj1, byte[] obj2)
        //{
        //    bool blnSame = false;
        //    if (obj1 != null && obj2 != null)
        //    {
        //        blnSame = Convert.ToBase64String(obj1) == Convert.ToBase64String(obj2);
        //    }

        //    return blnSame;
        //}

        //public virtual object GetPropertyValue(object obj, string propertyName)
        //{
        //    return obj.GetType().GetProperty(propertyName) == null ? "" : obj.GetType().GetProperty(propertyName).GetValue(obj, null);
        //}
        //public virtual bool CompareDateTime(object obj1, object obj2)
        //{
        //    bool blnResult;
        //    if (obj1 is DateTime && obj2 is DateTime)
        //    {
        //        if (Convert.ToDateTime(obj1).ToString("yyyyMMddHHmmss") != Convert.ToDateTime(obj2).ToString("yyyyMMddHHmmss"))
        //        {
        //            blnResult = false;
        //        }
        //        else
        //        {
        //            blnResult = true;
        //        }
        //    }
        //    else
        //    {
        //        blnResult = false;
        //    }
        //    return blnResult;
        //}

    }
}
