// Copyright (C) Stichting Deltares 2017. All rights reserved.
//
// This file is part of the Dam Engine.
//
// The Dam Engine is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System;
using System.Collections.Generic;
using Deltares.DamEngine.Data.Standard.Language;
namespace Deltares.DamEngine.Data.Standard.Validation
{
///
/// Class ValidationResult
///
///
[Serializable]
public class ValidationResult : IValidationResult
{
///
/// Initializes a new instance of the class.
///
public ValidationResult() : this(ValidationResultType.Error, string.Empty) {}
///
/// Initializes a new instance of the class.
///
/// Type of the message.
/// The text.
public ValidationResult(ValidationResultType messageType, string text)
: this(messageType, text, null) {}
///
/// Initializes a new instance of the class.
///
/// Type of the message.
/// The text.
/// The object for which the message is of interest (shown in the second column)
public ValidationResult(ValidationResultType messageType, string text, object subject)
{
MessageType = messageType;
Text = text;
Subject = subject;
InvalidProperties = new List();
ID = new List();
}
///
/// Initializes a new instance of the class.
///
/// Type of the message.
/// The text.
/// The object for which the message is of interest (shown in the second column)
/// ID for the message (note: does not seem to be shown)
public ValidationResult(ValidationResultType messageType, string text, string id, object subject)
: this(messageType, text, subject, "", id) {}
///
/// Initializes a new instance of the class.
///
/// Type of the message.
/// The text.
/// The object for which the message is of interest (shown in the second column)
/// Property for which the message was issued (note: does not seem to be shown)
/// ID for the message (note: does not seem to be shown)
public ValidationResult(ValidationResultType messageType, string text, object subject, string property, string id)
{
MessageType = messageType;
Text = text;
Subject = subject;
InvalidProperties = new List
{
property
};
ID = new List
{
id
};
}
#region IValidationResult Members
///
/// Gets the identifier.
///
///
/// The identifier.
///
public List ID { get; private set; }
///
/// Gets the invalid properties.
///
///
/// The invalid properties.
///
public List InvalidProperties { get; private set; }
///
/// Gets the type of the message.
///
///
/// The type of the message.
///
public ValidationResultType MessageType { get; set; }
///
/// Gets or sets the text.
///
///
/// The text.
///
[Translation("Message")]
public string Text { get; set; }
///
/// Gets or sets the subject.
///
///
/// The subject.
///
public object Subject { get; set; }
#endregion
///
/// Adds the property and identifier.
///
/// The property.
/// The identifier.
public void AddPropertyAndId(string property, string aId)
{
InvalidProperties.Add(property);
ID.Add(aId);
}
///
/// Clears the validation result.
///
public void ClearValidationResult()
{
Subject = null;
if (InvalidProperties != null)
{
InvalidProperties.Clear();
}
if (ID != null)
{
ID.Clear();
}
}
}
}