using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace SystemX.Net
{
    public static class Base
    {
        public static bool CheckPath(string strPath)
        {
            Regex r = new Regex(@"^(([a-zA-Z]\:)|(\\))(\\{1}|((\\{1})[^\\]([^/:*?<>""|]*))+)$");
            return r.IsMatch(strPath);
        }
    }


    //Table Info(Serializatiopn) object.
    [Serializable]
    public class XTable
    {
        public string tableName;

        public List<int> lstIndex;
        public List<string> lstName;
        public List<Type> lstType;
        public List<int> lstCharSize;
        public List<bool> lstNullAble;

        public XTable(string fName)
        {
            this.tableName = fName;

            lstIndex = new List<int>();
            lstName = new List<string>();
            lstType = new List<Type>();
            lstCharSize = new List<int>();
            lstNullAble = new List<bool>();
        }
        public void XTableAdd(int iIndex, string strName, Type SetType, int iCharSize, bool bNullable)
        {
            lstIndex.Add(iIndex);
            lstName.Add(strName);
            lstType.Add(SetType);
            lstCharSize.Add(iCharSize);
            lstNullAble.Add(bNullable);
        }
    }
    public enum eLogDataType
    {
        None = -1,

        //CpLog
        Normal = 0,

        //Leak
        CSV_Type0 = 1,

        //Laser Trimming Vision
        CSV_Type1 = 2,

        //Pin Vision
        CSV_Type2 = 3
    }
    public enum eLogAccessType
    {
        None = -1,

        //File
        FileData = 0,

        //VarBinary
        VarBinaryData = 1,
    }

    // implements IEnumerable so that it can be used
    [Serializable]
    public class XTableInfo : IEnumerable
    {
        public XTable[] _table;
        public XTableInfo(XTable[] pArrayTable)
        {
            _table = new XTable[pArrayTable.Length];

            for (int i = 0; i < pArrayTable.Length; i++)
            {
                _table[i] = pArrayTable[i];
            }
        }

        // Implementation for the GetEnumerator method.
        IEnumerator IEnumerable.GetEnumerator()
        {
            return (IEnumerator)GetEnumerator();
        }

        public TableEnum GetEnumerator()
        {
            return new TableEnum(_table);
        }
    }

    //implement IEnumerable, implement IEnumerator.
    [Serializable]
    public class TableEnum : IEnumerator
    {
        public XTable[] _table;

        // Enumerators are positioned before the first element
        // until the first MoveNext() call.
        int position = -1;

        public TableEnum(XTable[] list)
        {
            _table = list;
        }

        public bool MoveNext()
        {
            position++;
            return (position < _table.Length);
        }

        public void Reset()
        {
            position = -1;
        }

        object IEnumerator.Current
        {
            get
            {
                return Current;
            }
        }

        public XTable Current
        {
            get
            {
                try
                {
                    return _table[position];
                }
                catch (IndexOutOfRangeException)
                {
                    throw new InvalidOperationException();
                }
            }
        }
    }
}
