Код: Выделить всё
public class CreateCPUCommand : IRequest
{
public int Article { get; set; }
public int Garanty { get; set; }
public int ServiceLife { get; set; }
public Model Model { get; set; }
public Socket Socket { get; set; }
public int GeneralCoresCount { get; set; }
public int HighPerformanceCoresCount { get; set; }
public int EnergyEfficientCoresCount { get; set; }
public int StreamsCount { get; set; }
public int BaseFrequency { get; set; }
public int MaxFrequencyInTurbo { get; set; }
public bool HasFreeMultiplier { get; set; }
public RAMType RAMType { get; set; }
public int RAMMaxSize { get; set; }
public int MaxTemperature { get; set; }
public bool HasGraphicCore { get; set; }
public int Price { get; set; }
}
Код: Выделить всё
public class CreateCPUCommandValidator : AbstractValidator
{
public CreateCPUCommandValidator()
{
RuleFor(createCpuCommand => createCpuCommand.GeneralCoresCount)
.Equal(createCpuCommand =>
createCpuCommand.EnergyEfficientCoresCount + createCpuCommand.HighPerformanceCoresCount);
RuleFor(createCpuCommand => createCpuCommand.Garanty)
.GreaterThan(0);
RuleFor(createCpuCommand => createCpuCommand.ServiceLife)
.GreaterThan(0);
RuleFor(createCpuCommand => createCpuCommand.GeneralCoresCount)
.GreaterThan(0);
RuleFor(createCpuCommand => createCpuCommand.HighPerformanceCoresCount)
.GreaterThan(0);
RuleFor(createCpuCommand => createCpuCommand.EnergyEfficientCoresCount)
.GreaterThan(0);
RuleFor(createCpuCommand => createCpuCommand.StreamsCount)
.GreaterThan(0);
RuleFor(createCpuCommand => createCpuCommand.BaseFrequency)
.GreaterThan(0);
RuleFor(createCpuCommand => createCpuCommand.MaxFrequencyInTurbo)
.GreaterThan(0);
RuleFor(createCpuCommand => createCpuCommand.RAMMaxSize)
.GreaterThan(0);
RuleFor(createCpuCommand => createCpuCommand.MaxTemperature)
.GreaterThan(0);
RuleFor(createCpuCommand => createCpuCommand.Price)
.GreaterThan(0);
}
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... properties
Мобильная версия