using System;
using ProtoBuf;
using Fantasy;
using System.Linq;
using System.Reflection;
using System.Collections.Generic;
using System.Collections.Concurrent;
using Fantasy.Serialize;
using Fantasy.ConfigTable;

namespace NBF
{
    [ProtoContract]
    public sealed partial class BasicConfig : ASerialize, IProto, IConfigTable
    {
    
		[ProtoMember(1)]
		public uint Id { get; set; } // Id
		[ProtoMember(2)]
		public string Name { get; set; } // 参数名
		[ProtoMember(3)]
		public string[] Val { get; set; } = Array.Empty<string>(); // 参数值  
        [ProtoIgnore]
        public uint Key => Id;
        
        #region Static
        
        private static ConfigContext<BasicConfig> Context => ConfigTableHelper.Table<BasicConfig>();

        public static BasicConfig Get(uint key)
        {
            return Context.Get(key);
        }

        public static BasicConfig Get(Predicate<BasicConfig> match)
        {
            return Context.Get(match);
        }
        
        public static BasicConfig Fist()
        {
            return Context.Fist();
        }

        public static BasicConfig Last()
        {
            return Context.Last();
        }

        public static BasicConfig Fist(Predicate<BasicConfig> match)
        {
            return Context.Fist(match);
        }

        public static BasicConfig Last(Predicate<BasicConfig> match)
        {
            return Context.Last(match);
        }
        
        public static int Count()
        {
            return Context.Count();
        }

        public static int Count(Func<BasicConfig, bool> predicate)
        {
            return Context.Count(predicate);
        }

        public static List<BasicConfig> GetList()
        {
            return Context.GetList();
        }

        public static List<BasicConfig> GetList(Predicate<BasicConfig> match)
        {
            return Context.GetList(match);
        }
        public static void ParseJson(Newtonsoft.Json.Linq.JArray arr)
        {
            ConfigTableHelper.ParseLine<BasicConfig>(arr);
        }
        #endregion
    }
}