/// <summary> /// Returns true if the <paramref name="type"/>is a SequenceType matching <paramref name="typeToMatch"/> /// </summary> /// <param name="type"></param> /// <param name="typeToMatch"></param> /// <returns></returns> public static bool IsSequenceContainingType(this IModelType type, KnownPrimaryType typeToMatch) { SequenceType sequenceType = type as SequenceType; PrimaryType sequencePrimaryType = sequenceType?.ElementType as PrimaryType; return(sequencePrimaryType != null && sequencePrimaryType.IsPrimaryType(typeToMatch)); }
/// <summary> /// Returns true if the <paramref name="type"/> is a DictionaryType with ValueType matching <paramref name="typeToMatch"/> /// </summary> /// <param name="type"></param> /// <param name="typeToMatch"></param> /// <returns></returns> public static bool IsDictionaryContainingType(this IModelType type, KnownPrimaryType typeToMatch) { DictionaryType dictionaryType = type as DictionaryType; PrimaryType dictionaryPrimaryType = dictionaryType?.ValueType as PrimaryType; return(dictionaryPrimaryType != null && dictionaryPrimaryType.IsPrimaryType(typeToMatch)); }
public static string GetEmptyCheck(this PrimaryType type, string valueReference, bool asEmpty) { if (type.IsPrimaryType(KnownPrimaryType.ByteArray)) { return(string.Format(asEmpty ? "{0} == nil || len({0}) == 0" : "{0} != nil && len({0}) > 0", valueReference)); } else if (type.IsPrimaryType(KnownPrimaryType.String)) { return(string.Format(asEmpty ? "len({0}) == 0" : "len({0}) > 0", valueReference)); } else { return(string.Format(asEmpty ? "{0} == nil" : "{0} != nil", valueReference)); } }