Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Async/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/3.1.3/EPPlus-3.1.3/Utils/ValidationResult.cs @ 13042

Last change on this file since 13042 was 9580, checked in by sforsten, 12 years ago

#1730:

  • added SymbolicDataAnalysisExpressionExcelFormatter
  • changed modifiers in SymbolicExpressionTreeChart of methods SaveImageAsBitmap and SaveImageAsEmf to public
  • added menu item ExportSymbolicSolutionToExcelMenuItem to export a symbolic solution to an excel file
  • added EPPlus-3.1.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.