Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/4.0.3/EPPlus-4.0.3/Utils/ValidationResult.cs @ 16204

Last change on this file since 16204 was 12074, checked in by sraggl, 10 years ago

#2341: Added EPPlus-4.0.3 to ExtLibs

File size: 1.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5
6namespace OfficeOpenXml.Utils
7{
8    public class ValidationResult : IValidationResult
9    {
10        public ValidationResult(bool result)
11            : this(result, null)
12        {
13           
14        }
15
16        public ValidationResult(bool result, string errorMessage)
17        {
18            _result = result;
19            _errorMessage = errorMessage;
20        }
21
22        private bool _result;
23        private string _errorMessage;
24
25        private void Throw()
26        {
27            if(string.IsNullOrEmpty(_errorMessage))
28            {
29                throw new InvalidOperationException();
30            }
31            throw new InvalidOperationException(_errorMessage);
32        }
33
34        void IValidationResult.IsTrue()
35        {
36            if (!_result)
37            {
38                Throw();
39            }
40        }
41
42        void IValidationResult.IsFalse()
43        {
44            if (_result)
45            {
46                Throw();
47            }
48        }
49    }
50}
Note: See TracBrowser for help on using the repository browser.