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

namespace IACommService4CSharp
{
    public enum ACCESS_TYPE
    {
        UNKNOW = 0,
        ONLY_READ,
        ONLY_WRITE,
        READ_WRITE
    }

    public class SymbolNodeInfo_t : ComplexBase_t
    {
        public SymbolNodeInfo_t() : base()
        {
        }
        //Internal use
        public SymbolNodeInfo_t(IDataValue4CSharp value) : base(value)
        {
        }
        public string Name
        {
            get
            {
                return GetFieldValue("Name") as string;
            }
            set
            {
                SetFieldValue("Name", value);
            }
        }
        public bool IsSymbol
        {
            get
            {
                return (bool)GetFieldValue("SymbolFlag");
            }
            set
            {
                SetFieldValue("SymbolFlag", value);
            }
        }
        public uint TypeID
        {
            get
            {
                return (uint)GetFieldValue("TypeID");
            }
            set
            {
                SetFieldValue("TypeID", value);
            }
        }
        public ACCESS_TYPE Access
        {
            get
            {
                var access = GetFieldValue("Access") as string;
                if (access == "r")
                {
                    return ACCESS_TYPE.ONLY_READ;
                }
                else if (access == "w")
                {
                    return ACCESS_TYPE.ONLY_WRITE;
                }
                else if (access == "b")
                {
                    return ACCESS_TYPE.READ_WRITE;
                }
                else
                {
                    return ACCESS_TYPE.UNKNOW;
                }
            }
            set
            {
                string access = "";
                if (value == ACCESS_TYPE.ONLY_READ)
                {
                    access = "r";
                }
                else if (value == ACCESS_TYPE.ONLY_WRITE)
                {
                    access = "w";
                }
                else if (value == ACCESS_TYPE.READ_WRITE)
                {
                    access = "b";
                }

                SetFieldValue("Access", access);
            }
        }
    }
}
