Esempio n. 1
0
        public void Send(Notice notice)
        {
            Type noticeType    = notice.GetType();
            var  notifyService = _notifyService.FirstOrDefault(m => m.SupportType == noticeType);

            if (notifyService != null)
            {
                notifyService.Send(notice);
            }
            else
            {
                throw new Exception($"未找到类型{noticeType}对应的通知器");
            }
        }
Esempio n. 2
0
        public void Send(Notice notice)
        {
            Type noticeType = notice.GetType();
            var  notifies   = _notifyService.Where(m => m.SupportType == noticeType);

            if (notifies.Any())
            {
                foreach (var item in notifies)
                {
                    item.Send(notice);
                }
            }
            else
            {
                throw new Exception($"未找到类型{noticeType}对应的通知器");
            }
        }
Esempio n. 3
0
        public JobType NoticeToJobType(Notice no)
        {
            if (no == null)
                throw new ArgumentNullException("Input to method NoticeToType was null.");

            if (no is DisruptJob)
                return JobType.Disrupt;
            else if (no is AttackJob)
                return JobType.Attack;
            else if (no is OccupyJob)
                return JobType.Occupy;
            else if (no is RepairJob)
                return JobType.Repair;
            else
                throw new ArgumentException("Input to NoticeToJobtype, object : " + no.GetType().Name + " was not of appropriate type. It's type was: " + no.GetType());
        }