/// <summary> /// Получить атрибут "Описание" /// </summary> public static string GetDescription(TypeSalary value) { FieldInfo fi = value.GetType().GetField(value.ToString()); DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false); if (attributes != null && attributes.Length > 0) { return(attributes[0].Description); } return(value.ToString()); }
public void GetSalary(TypeSalary key, params uint[] value) { switch (key) { case TypeSalary.Hourly: { EmployeeBase salary = SalaryFactory.GetSalary(TypeSalary.Hourly, 140, 400); EmployeeHourly result = salary as EmployeeHourly; Assert.AreSame(salary, result); break; } case TypeSalary.Rate: { EmployeeBase salary = SalaryFactory.GetSalary(TypeSalary.Rate, 180, 100000, 180); EmployeeRate result = salary as EmployeeRate; Assert.AreSame(salary, result); break; } } }
/// <summary> /// Вернуть зарплату определённого типа /// </summary> public static EmployeeBase GetSalary(TypeSalary key, params uint[] value) { switch (key) { case TypeSalary.Hourly: if (value.Length == 2) { return(new EmployeeHourly(value[0], value[1])); } break; case TypeSalary.Rate: if (value.Length == 3) { return(new EmployeeRate(value[0], value[1], value[2])); } break; default: throw new ArgumentOutOfRangeException(nameof(key), key, null); } throw new ArgumentException("Ошибка ввода. Введите корректные значения"); }