using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace Util.ObjectMapping.AutoMapper.Tests.Samples;
public interface ISample {
}
///
/// 测试样例
///
[Description( "测试样例" )]
public class Sample : ISample {
///
/// 初始化测试样例
///
public Sample() {
StringList = new List();
StringArray = StringList.ToArray();
}
///
/// 测试值
///
[Display( Name = "测试值" )]
[Required( ErrorMessage = "测试值不能为空" )]
[StringLength( 20, ErrorMessage = "测试值长度不能超过20" )]
[EmailAddress]
[Url]
public string TestValue { get; set; }
///
/// 电子邮件验证
///
[EmailAddress( ErrorMessage = "电子邮件不正确" )]
public string Email { get; set; }
///
/// 网址验证
///
[Url( ErrorMessage = "网址不正确" )]
public string Url { get; set; }
///
/// 最大长度
///
[MaxLength( 2, ErrorMessage = "最大长度是2" )]
public string MaxLengthValue { get; set; }
///
/// 长度验证
///
[StringLength( 3, MinimumLength = 2, ErrorMessage = "最大长度是3,最小长度是2" )]
public string StringLengthValue { get; set; }
///
/// DisplayName
///
[DisplayName( "DisplayNameValue值" )]
public string DisplayNameValue { get; set; }
///
/// Display
///
[Display( Name = "DisplayValue值" )]
public string DisplayValue { get; set; }
///
/// string值
///
[Display( Name = "字符串值" )]
[StringLength( 20, ErrorMessage = "长度不能超过20" )]
[Required( ErrorMessage = "不能为空" )]
public string StringValue { get; set; }
///
/// decimal值
///
public decimal DecimalValue { get; set; }
///
/// 可空decimal值
///
public decimal? NullableDecimalValue { get; set; }
///
/// float值
///
public float FloatValue { get; set; }
///
/// 可空float值
///
public float? NullableFloatValue { get; set; }
///
/// double值
///
public double DoubleValue { get; set; }
///
/// 可空double值
///
public double? NullableDoubleValue { get; set; }
///
/// bool值
///
public bool BoolValue { get; set; }
///
/// 可空bool值
///
public bool? NullableBoolValue { get; set; }
///
/// Enum值
///
public EnumSample EnumValue { get; set; }
///
/// 可空Enum值
///
public EnumSample? NullableEnumValue { get; set; }
///
/// DateTime值
///
public DateTime DateValue { get; set; }
///
/// 可空DateTime值
///
public DateTime? NullableDateValue { get; set; }
///
/// int值
///
[Description( "IntValue" )]
public int IntValue { get; set; }
///
/// 可空int值
///
public int? NullableIntValue { get; set; }
///
/// short值
///
public short ShortValue { get; set; }
///
/// 可空short值
///
public short? NullableShortValue { get; set; }
///
/// long值
///
public long LongValue { get; set; }
///
/// 可空long值
///
public long? NullableLongValue { get; set; }
///
/// 字符串列表
///
public List StringList { get; set; }
///
/// 字符串数据
///
public string[] StringArray { get; set; }
///
/// Guid值
///
public Guid GuidValue { get; set; }
///
/// 测试2
///
public Sample2 Test2 { get; set; }
///
/// 测试3
///
public Sample3Copy Test3 { get; set; }
///
/// 导航属性
///
public List TestList { get; set; }
///
/// 静态属性
///
public static string StaticString => "TestStaticString";
///
/// 静态对象
///
public static Sample2 StaticSample => new Sample2 { StringValue = "TestStaticSample" };
///
/// 创建测试实例1
///
public static Sample Create1() {
return new Sample { StringValue = "A" };
}
///
/// 创建测试实例2
///
public static Sample Create2() {
return new Sample { StringValue = "B" };
}
}