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

namespace MixTraffic
{
    internal class CommonCluster
    {
        private int _ID;
        private int _Address;
        private string _Edges;
        private int _OccupiedWay;
        protected internal virtual int ID
        {
            get
            {
                return _ID;
            }

            set
            {
                _ID = value;
            }
        }
        protected internal virtual int Address
        {
            get
            {
                return _Address;
            }

            set
            {
                _Address = value;
            }
        }
        protected internal virtual int OccupiedWay
        {
            get
            {
                return _OccupiedWay;
            }

            set
            {
                _OccupiedWay = value;
            }
        }
        protected internal virtual string Edges
        {
            get
            {
                return _Edges;
            }

            set
            {
                _Edges = value;
            }
        }

        public virtual List<int> EdgeInts
        {
            get
            {
                List<int> result = new List<int>();
                try
                {
                    string[] strs = _Edges.Split(',');
                    foreach (var item in strs)
                    {
                        int a;
                        if (int.TryParse(item, out a) && !result.Contains(a))
                        {
                            result.Add(a);
                        }
                    }
                }
                catch
                {

                }
                return result;
            }
        }
    }
    class MappingCommonCluster : ClassMap<CommonCluster>
    {
        public MappingCommonCluster()
        {
            Table("PMS_traffic_CommonCluster");
            Id(m => m.ID).GeneratedBy.Assigned();//.Increment();
            Map(m => m.Address);
            Map(m => m.OccupiedWay);
            Map(m => m.Edges);
        }
    }
}
