public StructureIndex(IStructureId structureId, string path, object value, Type dataType, DataTypeCode dataTypeCode, StructureIndexType indexType = StructureIndexType.Normal) { var valueIsOkType = value is string || value is ValueType; if (value != null && !valueIsOkType) throw new ArgumentException(ExceptionMessages.StructureIndex_ValueArgument_IncorrectType); Ensure.That(structureId, "structureId").IsNotNull(); Ensure.That(path, "path").IsNotNullOrWhiteSpace(); Ensure.That(dataType, "dataType").IsNotNull(); StructureId = structureId; Path = path; Value = value; DataType = dataType; DataTypeCode = dataTypeCode; IndexType = indexType; IsUnique = indexType.IsUnique(); }
public StructureIndex(IStructureId structureId, string path, object value, Type dataType, DataTypeCode dataTypeCode, StructureIndexType indexType = StructureIndexType.Normal) { var valueIsOkType = value is string || value is ValueType; if (value != null && !valueIsOkType) { throw new ArgumentException(ExceptionMessages.StructureIndex_ValueArgument_IncorrectType); } Ensure.That(structureId, "structureId").IsNotNull(); Ensure.That(path, "path").IsNotNullOrWhiteSpace(); Ensure.That(dataType, "dataType").IsNotNull(); StructureId = structureId; Path = path; Value = value; DataType = dataType; DataTypeCode = dataTypeCode; IndexType = indexType; IsUnique = indexType.IsUnique(); }
public static bool IsUnique(this StructureIndexType indexType) { return(indexType == StructureIndexType.UniquePerInstance || indexType == StructureIndexType.UniquePerType); }