Ejemplo n.º 1
0
        /// <summary>
        /// 設定データを文字列化します。
        /// </summary>
        /// <param name="src">対象項目</param>
        /// <returns>設定データ文字列</returns>
        public static string ToPrint(this CheckInfo src)
        {
            switch (src.Mode)
            {
            case SetMode.Terms:
                var dts = Date.FromTerm(src.Data, 2017);
                return((dts == null) ? "" : string.Join(" to ", dts.Where(x => x != DateTime.MinValue && x != DateTime.MaxValue).Select(x => x.ToString("yyyy/MM/dd HH:mm"))));

            case SetMode.Frequency:
                var fqs = Frequency.Split(src.Data);
                return((fqs == null) ? "" : fqs.Join());

            case SetMode.PowerMode:
                var pms = PowerMode.ToArray(src.Data);
                return((pms == null) ? "" : string.Join(", ", pms.Select(x => x.ToString())));

            case SetMode.Sector:
                var data = src.Data.Replace("\r\n", "`");
                var scs  = Sectors.ToArray(data)?.ToArray();
                return((scs == null) ? "" : string.Join("\r\n", scs.Select(x => x.ToString())));

            default:
                return(src.Data.ToString());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 0から始まる対象の部門番号を取得
        /// </summary>
        /// <param name="Category">対象カテゴリ</param>
        /// <param name="General">コンテスト設定 (一般)リスト</param>
        /// <returns>部門番号</returns>
        public static int GetCategoryIndex(string Category, List <CheckInfo> General)
        {
            int ret = -1;

            var sec = Sectors.ToArray(General.GetByName("Sectors")).ToList();

            for (int i = 0; i < sec.Count; i++)
            {
                if (Category == "(" + sec[i].Code + ")" + sec[i].WrittenName)
                {
                    ret = i;
                    break;
                }
            }

            return(ret);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// `で連結した部門定義文字列を部門配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        public static IEnumerable <Sectors> ToArray(string str)
        {
            if (str.IsEmpty())
            {
                yield return(null);
            }

            var     spl     = str.Split('`');
            var     pattern = @"([^;]*;)+";         //g1 c0-5
            Sectors ret;

            foreach (var s in spl)
            {
                ret = null;
                if (!Regex.IsMatch(s, pattern))
                {
                    continue;
                }
                var m = Regex.Match(s, pattern)?.Groups[1]?.Captures.Cast <Capture>()?.Select(x => x.ToString().TrimEnd(';'))?.ToArray();
                if (m == null)
                {
                    continue;
                }
                try {
                    ret = new Sectors()
                    {
                        Name         = m[0],
                        WrittenName  = (m[1] == "") ? m[0] : m[1],
                        Code         = m[2],
                        Modes        = m[3].Split(',').IntParse().ToArray(),
                        EnabledFreqs = m[4].Split(',').Select(y => Frequency.FromString(y)).ToArray(),
                        UnabledFreqs = m[5].Split(',').Select(y => Frequency.FromString(y)).ToArray(),
                    };
                } catch (Exception e) {
                    Console.WriteLine(e.Message);
                    continue;
                }

                yield return(ret);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 対象の部門データを取得
 /// </summary>
 /// <param name="Category">対象カテゴリ</param>
 /// <param name="General">コンテスト設定 (一般)リスト</param>
 /// <returns>部門データ</returns>
 public static Sectors GetSectorFromCategory(string Category, List <CheckInfo> General)
 {
     return(Sectors.ToArray(General.GetByName("Sectors"))?.FirstOrDefault(x => Category == "(" + x.Code + ")" + x.WrittenName));
 }