Exemplo n.º 1
0
 /// <summary>檢查有資料</summary>
 public static void Has(object value, string errorMessage)
 {
     if (OrionUtils.HasValue(value))
     {
         return;
     }
     throwException(errorMessage, value);
 }
Exemplo n.º 2
0
        /// <summary>檢查是否符合狀態轉換規則</summary>
        public static void StatusRule <T, Allow>(T fromStatus, T toStatus, IDictionary <T, Allow> rule, string errorMessage) where Allow : IEnumerable <T>
        {
            var allow = Enumerable.Empty <T>();

            if (rule.ContainsKey(fromStatus))
            {
                allow = rule[fromStatus];
            }
            if (allow.Contains(toStatus))
            {
                return;
            }

            string fromStatusStr = OrionUtils.GetEnumDisplayName(fromStatus) ?? fromStatus.ToString();
            string toStatusStr   = OrionUtils.GetEnumDisplayName(toStatus) ?? toStatus.ToString();

            throwException(errorMessage, fromStatusStr, toStatusStr);
        }