260 lines
6.0 KiB
C#
260 lines
6.0 KiB
C#
//
|
|
// Class: ValidationAttribute
|
|
// Current CLR: 4.0.30319.34209
|
|
// System: Microsoft Visual Studio 10.0
|
|
// Author: dani
|
|
// Created: 9/7/2015 8:32:30 AM
|
|
//
|
|
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace bsmd.database
|
|
{
|
|
|
|
#region ValidationCode
|
|
|
|
public enum ValidationCode
|
|
{
|
|
|
|
NONE,
|
|
NOT_NULL,
|
|
LOCODE,
|
|
LOCODE_GER,
|
|
GISIS,
|
|
INT_GT_ZERO, // 5
|
|
DOUBLE_GT_ZERO,
|
|
FLAG_CODE,
|
|
TWO_DIGIT,
|
|
STRING_MAXLEN,
|
|
STRING_EXACT_LEN, // 10
|
|
LIST_EMPTY,
|
|
IMPLAUSIBLE,
|
|
IMPLAUSIBLE_ZZUKN,
|
|
LOCODE_NOPORT,
|
|
LOCODE_SSN, // 15
|
|
DOT_NO_COMMA,
|
|
VESSEL_TYPE,
|
|
NOT_NULL_MAX_LEN,
|
|
FRZ,
|
|
POSITION_COUNT = 22,
|
|
STRING_UNNUMBER = 23,
|
|
STRING_IMOCLASS = 24,
|
|
DRAUGHT_IMPLAUSIBLE = 25,
|
|
TIME_IMPLAUSIBLE = 26,
|
|
PORTAREA,
|
|
TRUNCATE = 28,
|
|
MMSI = 29,
|
|
INVALID_NUMBER_CHARS = 30,
|
|
OPTIONAL_FLAG_CODE,
|
|
WORDOVERFLOW,
|
|
VALUE_TOO_LARGE,
|
|
PAST_DATE,
|
|
V181 = 181,
|
|
V182,
|
|
E121 = 121,
|
|
E122 = 122,
|
|
E123 = 123,
|
|
E124 = 124,
|
|
E125 = 125,
|
|
V201 = 201,
|
|
V202,
|
|
V203,
|
|
V221 = 221,
|
|
V701 = 701,
|
|
V702 = 702,
|
|
V703 = 703,
|
|
V704 = 704,
|
|
V705 = 705,
|
|
V706 = 706,
|
|
V721 = 721,
|
|
V741 = 741,
|
|
V761 = 761,
|
|
V762 = 762,
|
|
V763 = 763,
|
|
V764 = 764,
|
|
V765 = 765,
|
|
V766 = 766,
|
|
V767 = 767,
|
|
V768 = 768,
|
|
V781 = 781,
|
|
V782 = 782,
|
|
V783 = 783,
|
|
V784 = 784,
|
|
V786 = 786,
|
|
V801 = 801,
|
|
V802 = 802,
|
|
V803 = 803,
|
|
V804 = 804,
|
|
V805 = 805,
|
|
V806 = 806,
|
|
V807 = 807,
|
|
V808 = 808,
|
|
V809 = 809,
|
|
V810 = 810,
|
|
V821 = 821,
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ENI2 Validierung
|
|
|
|
/// <summary>
|
|
/// Wenn ein Property damit dekoriert ist, steht es im Validierungs-Editor als Parameter zur Verfügung
|
|
/// </summary>
|
|
[AttributeUsage(AttributeTargets.Property)]
|
|
public class ENI2ValidationAttribute : Attribute
|
|
{
|
|
public ENI2ValidationAttribute() { }
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region allg. ValidationAttribute (wird immer geprüft)
|
|
|
|
[AttributeUsage(AttributeTargets.Property)]
|
|
public class ValidationAttribute : Attribute
|
|
{
|
|
private ValidationCode validationCode;
|
|
private int maxlen;
|
|
|
|
public ValidationAttribute(ValidationCode code)
|
|
{
|
|
this.validationCode = code;
|
|
}
|
|
|
|
public ValidationAttribute(ValidationCode code, int maxlen)
|
|
{
|
|
this.maxlen = maxlen;
|
|
this.validationCode = code;
|
|
}
|
|
|
|
public int MaxLen
|
|
{
|
|
get { return this.maxlen; }
|
|
set { this.maxlen = value; }
|
|
}
|
|
|
|
public ValidationCode Code
|
|
{
|
|
get { return this.validationCode; }
|
|
set { this.validationCode = value; }
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Block 1 (entweder-oder Sektion) Attribut wird nur im Fall Block 1 geprüft
|
|
|
|
[AttributeUsage(AttributeTargets.Property)]
|
|
public class Validation1Attribute : Attribute
|
|
{
|
|
private ValidationCode validationCode;
|
|
private int maxlen;
|
|
|
|
|
|
public Validation1Attribute(ValidationCode code)
|
|
{
|
|
this.validationCode = code;
|
|
}
|
|
|
|
public Validation1Attribute(ValidationCode code, int maxlen)
|
|
{
|
|
this.maxlen = maxlen;
|
|
this.validationCode = code;
|
|
}
|
|
|
|
public int MaxLen
|
|
{
|
|
get { return this.maxlen; }
|
|
set { this.maxlen = value; }
|
|
}
|
|
|
|
public ValidationCode Code
|
|
{
|
|
get { return this.validationCode; }
|
|
set { this.validationCode = value; }
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Block 2 (entweder-oder Sektion) Attribut wird nur im Fall Block 2 geprüft
|
|
|
|
[AttributeUsage(AttributeTargets.Property)]
|
|
public class Validation2Attribute : Attribute
|
|
{
|
|
private ValidationCode validationCode;
|
|
private int maxlen;
|
|
|
|
public Validation2Attribute(ValidationCode code)
|
|
{
|
|
this.validationCode = code;
|
|
}
|
|
|
|
public Validation2Attribute(ValidationCode code, int maxlen)
|
|
{
|
|
this.maxlen = maxlen;
|
|
this.validationCode = code;
|
|
}
|
|
|
|
public int MaxLen
|
|
{
|
|
get { return this.maxlen; }
|
|
set { this.maxlen = value; }
|
|
}
|
|
|
|
public ValidationCode Code
|
|
{
|
|
get { return this.validationCode; }
|
|
set { this.validationCode = value; }
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Überprüfung der maximalen String-Länge
|
|
|
|
[AttributeUsage(AttributeTargets.Property)]
|
|
public class MaxLengthAttribute : Attribute
|
|
{
|
|
private int maxLength;
|
|
|
|
public MaxLengthAttribute(int length)
|
|
{
|
|
this.maxLength = length;
|
|
}
|
|
|
|
public int MaxLength
|
|
{
|
|
get { return this.maxLength; }
|
|
set { this.maxLength = value; }
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Überprüfung der maximalen Wort/Text-Länge innerhalb eines Strings
|
|
|
|
[AttributeUsage(AttributeTargets.Property)]
|
|
public class MaxWordLengthAttribute : Attribute
|
|
{
|
|
private int maxWordLength;
|
|
|
|
public MaxWordLengthAttribute(int length)
|
|
{
|
|
this.maxWordLength = length;
|
|
}
|
|
|
|
public int MaxWordLength
|
|
{
|
|
get { return this.maxWordLength; }
|
|
set { this.maxWordLength = value; }
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|