Rev | Line | |
---|
[12074] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 |
|
---|
| 6 | namespace 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.