/// <summary> /// Checks whether the value satisfies constraints. /// If not, throws an exception. /// </summary> /// <param name="value"></param> protected void CheckValue(object value) { if (value == null) { return; } if (value is string) { return; } Type type = value.GetType(); if (type.IsArray) // 1d array { type = type.GetElementType(); if (!DataSet.IsSupported(type)) { throw new NotSupportedException("Type " + value.GetType() + " is not supported by metadata dictionary"); } Array array = (Array)value; if (array.Rank != 1) { throw new NotSupportedException("Metadata supports only 1d-arrays"); } if (type == typeof(string)) { if (!Array.TrueForAll((string[])array, p => p != null)) { throw new NotSupportedException("String array in metadata cannot contain null"); } } } else // scalar { if (!DataSet.IsSupported(type)) { throw new NotSupportedException("Type " + value.GetType() + " is not supported by metadata dictionary"); } } }