private static bool IsConvertable(Type type) { return(type != typeof(T) && (type == typeof(string) || QowaivType.IsDate(type))); }
/// <summary>Returns true if the object type is (nullable) IJsonSerializable.</summary> /// <param name="objectType"> /// The object type to convert. /// </param> public override bool CanConvert(Type objectType) { return(objectType != null && (QowaivType.IsIJsonSerializable(objectType) || QowaivType.IsNullableIJsonSerializable(objectType))); }
/// <summary>Returns true if the conversion is supported.</summary> protected virtual bool IsConvertable(Type type) => type != typeof(TSvo) && QowaivType.IsNumeric(type);
public void Analize_AllSvos_MatchAttribute() { var assemblies = new[] { typeof(Date).Assembly, typeof(Qowaiv.Data.SvoParameter).Assembly, typeof(Qowaiv.Web.InternetMediaType).Assembly, }; var svos = assemblies.SelectMany(assembly => assembly.GetTypes()) .Where(tp => QowaivType.IsSingleValueObject(tp)) .OrderBy(tp => tp.Namespace) .ThenBy(tp => tp.Name) .ToArray(); var exp = new[] { typeof(Date), typeof(EmailAddress), typeof(Gender), typeof(HouseNumber), typeof(LocalDateTime), typeof(Month), typeof(Percentage), typeof(PostalCode), typeof(Uuid), typeof(WeekDate), typeof(Year), typeof(Qowaiv.Financial.Amount), typeof(Qowaiv.Financial.BankIdentifierCode), typeof(Qowaiv.Financial.Currency), typeof(Qowaiv.Financial.InternationalBankAccountNumber), typeof(Qowaiv.Financial.Money), typeof(Qowaiv.Globalization.Country), typeof(Qowaiv.IO.StreamSize), typeof(Qowaiv.Security.Cryptography.CryptographicSeed), typeof(Qowaiv.Sql.Timestamp), typeof(Qowaiv.Statistics.Elo), typeof(Qowaiv.Web.InternetMediaType) }; foreach (var svo in svos) { Console.WriteLine(svo); } CollectionAssert.AreEqual(exp, svos); foreach (var svo in svos) { var attr = QowaivType.GetSingleValueObjectAttribute(svo); SvoAssert.UnderlyingTypeMatches(svo, attr); SvoAssert.ParseMatches(svo, attr); SvoAssert.TryParseMatches(svo, attr); SvoAssert.IsValidMatches(svo, attr); SvoAssert.EmptyAndUnknownMatches(svo, attr); SvoAssert.ImplementsInterfaces(svo); SvoAssert.AttributesMatches(svo); } }