zhao
2021-06-04 c7ec496f9e41c2227103b3ef776e4a3f91bce6b2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace HH.WMS.Utils.EPPlus.Utils
{
    public class ValidationResult : IValidationResult
    {
        public ValidationResult(bool result)
            : this(result, null)
        {
            
        }
 
        public ValidationResult(bool result, string errorMessage)
        {
            _result = result;
            _errorMessage = errorMessage;
        }
 
        private bool _result;
        private string _errorMessage;
 
        private void Throw()
        {
            if(string.IsNullOrEmpty(_errorMessage))
            {
                throw new InvalidOperationException();
            }
            throw new InvalidOperationException(_errorMessage);
        }
 
        void IValidationResult.IsTrue()
        {
            if (!_result)
            {
                Throw();
            }
        }
 
        void IValidationResult.IsFalse()
        {
            if (_result)
            {
                Throw();
            }
        }
    }
}