public string GetString([NotNull] IRow errorRow, [NotNull] AttributeRole role) { const bool roleIsOptional = false; return(Assert.NotNull(GetString(errorRow, role, roleIsOptional))); }
internal string GetFieldName([NotNull] AttributeRole attributeRole) { // TODO: Consider implementing a configuration consistency check at the beginning string fieldName = null; foreach (IssueDatasetWriter issueWriter in GetIssueWriters()) { if (fieldName == null) { fieldName = issueWriter.GetAttribute(attributeRole).Name; } else if (!fieldName.Equals( issueWriter.GetAttribute(attributeRole).Name, StringComparison.OrdinalIgnoreCase)) { throw new InvalidConfigurationException( string.Format( "The field with role '{0}' must have the same name in all issue tables.", attributeRole)); } } Assert.NotNull(fieldName, "Field for role '{0}' not found in issue datasets", attributeRole); return(fieldName); }
public void WriteValue([NotNull] IRowBuffer rowBuffer, [NotNull] AttributeRole role, [CanBeNull] string text) { int fieldIndex = GetFieldIndex(role); WriteTextValue(text, rowBuffer, fieldIndex); }
public void WriteValue([NotNull] IRowBuffer rowBuffer, [NotNull] AttributeRole role, [CanBeNull] object value) { int fieldIndex = GetFieldIndex(role); rowBuffer.set_Value(fieldIndex, value ?? DBNull.Value); }
protected object GetValue([NotNull] AttributeRole role, bool roleIsOptional) { int?index = GetFieldIndex(role, _fieldIndexCache, roleIsOptional); return(index == null ? null : _object.Value[index.Value]); }
protected string GetString([NotNull] AttributeRole role) { object value = GetValue(role); return(value is DBNull ? null : (string)value); }
protected string GetDisplayValue([NotNull] AttributeRole role) { // don't call in tight loops int index = GetFieldIndex(role, _fieldIndexCache); object value = GdbObjectUtils.GetDisplayValue(_object, index); // NOTE: explicit cast to string results in exception if the domain code could not be resolved return(Convert.ToString(value)); }
private IField GetField([NotNull] IFields fields, AttributeRole role, out int fieldIndex) { string name = _fieldNames[role]; fieldIndex = fields.FindField(name); return(fields.Field[fieldIndex]); }
public static int GetFieldIndex([NotNull] ITable table, [NotNull] Attribute attribute, [CanBeNull] IFieldIndexCache fieldIndexCache = null) { AttributeRole attributeRole = (attribute as ObjectAttribute)?.Role; return (fieldIndexCache?.GetFieldIndex(table, attribute.Name, attributeRole) ?? GetFieldIndex(table, attribute.Name, attributeRole)); }
private int GetFieldIndex([NotNull] AttributeRole role, bool roleIsOptional) { int fieldIndex; if (!_fieldIndexesByRole.TryGetValue(role, out fieldIndex)) { fieldIndex = GetFieldIndexCore(role, roleIsOptional); _fieldIndexesByRole.Add(role, fieldIndex); } return(fieldIndex); }
public int GetFieldIndex([NotNull] string fieldName, [CanBeNull] AttributeRole role) { int fieldIndex; if (!_fieldIndexes.TryGetValue(fieldName, out fieldIndex)) { fieldIndex = AttributeUtils.GetFieldIndex(_table, fieldName, role); _fieldIndexes.Add(fieldName, fieldIndex); } return(fieldIndex); }
public int GetFieldIndex(ITable table, string fieldName, AttributeRole role) { FieldIndexes fieldIndexes; if (!_fieldIndexesByTable.TryGetValue(table, out fieldIndexes)) { fieldIndexes = new FieldIndexes(table); _fieldIndexesByTable.Add(table, fieldIndexes); } return(fieldIndexes.GetFieldIndex(fieldName, role)); }
private int GetFieldIndex([NotNull] AttributeRole role, [CanBeNull] IFieldIndexCache fieldIndexCache) { const bool roleIsOptional = false; int? result = GetFieldIndex(role, fieldIndexCache, roleIsOptional); if (result == null) { throw new InvalidOperationException("field index expected"); } return(result.Value); }
protected bool?GetBoolean([NotNull] AttributeRole role) { object value = GetValue(role); if (value == null || value is DBNull) { return(null); } const int trueValue = 1; return(Equals(value, trueValue)); }
public static string ToString(this AttributeRole attributeRole) { switch (attributeRole) { case AttributeRole.Dimension: return("Dimension"); case AttributeRole.Measure: return("Measure"); default: return("Unknown type"); } }
public int GetFieldLength([NotNull] AttributeRole role) { int length; if (!_fieldLengthByRole.TryGetValue(role, out length)) { IField field = Table.Fields.Field[GetFieldIndex(role)]; length = field.Length; _fieldLengthByRole.Add(role, length); } return(length); }
private ObjectAttribute GetAttribute([NotNull] AttributeRole attributeRole, bool roleIsOptional) { // TODO: Test if there are uow problems here ObjectAttribute attribute = _issueObjectDataset.GetAttribute(attributeRole); if (attribute != null || roleIsOptional) { return(attribute); } throw new InvalidConfigurationException( string.Format("Attribute role {0} does not exist in {1}", attributeRole, _issueObjectDataset.Name)); }
public string GetString([NotNull] IRow errorRow, [NotNull] AttributeRole role, bool roleIsOptional) { int fieldIndex = GetFieldIndex(role, roleIsOptional); if (fieldIndex < 0) { return(null); } object obj = errorRow.Value[fieldIndex]; return(obj == null || obj is DBNull ? string.Empty : Convert.ToString(obj)); }
public static int GetFieldIndex([NotNull] ITable table, [NotNull] string fieldName, [CanBeNull] AttributeRole attributeRole) { // TODO search first based on name, or first based on role? if (Equals(attributeRole, AttributeRole.Shape)) { var featureClass = table as IFeatureClass; if (featureClass != null) { return(table.FindField(featureClass.ShapeFieldName)); } } else if (Equals(attributeRole, AttributeRole.ShapeArea)) { var featureClass = table as IFeatureClass; if (featureClass != null) { IField areaField = DatasetUtils.GetAreaField(featureClass); if (areaField != null) { return(table.FindField(areaField.Name)); } } } else if (Equals(attributeRole, AttributeRole.ShapeLength)) { var featureClass = table as IFeatureClass; if (featureClass != null) { IField lengthField = DatasetUtils.GetLengthField(featureClass); if (lengthField != null) { return(table.FindField(lengthField.Name)); } } } else if (Equals(attributeRole, AttributeRole.ObjectID)) { return(table.FindField(table.OIDFieldName)); } return(table.FindField(fieldName)); }
private int GetFieldIndexCore([NotNull] AttributeRole role, bool roleIsOptional) { ObjectAttribute attribute = GetAttribute(role, roleIsOptional); if (attribute == null) { return(-1); } int fieldIndex = AttributeUtils.GetFieldIndex(Table, attribute, _fieldIndexCache); if (fieldIndex >= 0 || roleIsOptional) { return(fieldIndex); } throw new ArgumentException(string.Format("Field {0} not found", attribute.Name)); }
private void Write([NotNull] IFeature feature, AttributeRole role, [CanBeNull] object value) { Assert.ArgumentNotNull(feature, nameof(feature)); int fieldIndex; IField field = GetField(feature.Fields, role, out fieldIndex); if (value == null || value is DBNull) { if (field.IsNullable) { feature.Value[fieldIndex] = DBNull.Value; } return; } if (field.Type != esriFieldType.esriFieldTypeString) { feature.Value[fieldIndex] = value; return; } var stringValue = value as string; Assert.NotNull(stringValue, "Unexpected value for text field: {0}", value); bool requiresTrim = stringValue.Length > field.Length; if (requiresTrim) { _msg.WarnFormat("Text is too long for field '{0}', cutting off: {1}", field.Name, stringValue); } string writeValue = requiresTrim ? stringValue.Substring(0, field.Length) : stringValue; feature.Value[fieldIndex] = writeValue; }
private int?GetFieldIndex([NotNull] AttributeRole role, [CanBeNull] IFieldIndexCache fieldIndexCache, bool roleIsOptional) { ObjectAttribute attribute = _dataset.GetAttribute(role); if (attribute == null) { if (roleIsOptional) { return(null); } throw new ArgumentException( string.Format("Dataset [{0}] has no attribute role [{1}]", _dataset.Name, role), nameof(role)); } return(AttributeUtils.GetFieldIndex(_object.Class, attribute, fieldIndexCache)); }
protected string GetFieldName([NotNull] AttributeRole attributeRole) { return(IssueDatasets.GetFieldName(attributeRole)); }
protected void SetValue([NotNull] AttributeRole role, [CanBeNull] object value) { int index = GetFieldIndex(role, _fieldIndexCache); _object.set_Value(index, value ?? DBNull.Value); }
public T?Get <T>([NotNull] IRow errorRow, [NotNull] AttributeRole role) where T : struct { return(GdbObjectUtils.ReadRowValue <T>(errorRow, GetFieldIndex(role))); }
protected object GetValue([NotNull] AttributeRole role) { const bool roleIsOptional = false; return(GetValue(role, roleIsOptional)); }
public bool HasAttribute([NotNull] AttributeRole attributeRole) { return(_issueObjectDataset.GetAttribute(attributeRole) != null); }
public ObjectAttribute GetAttribute([NotNull] AttributeRole attributeRole) { const bool roleIsOptional = false; return(Assert.NotNull(GetAttribute(attributeRole, roleIsOptional))); }
private int GetFieldIndex([NotNull] AttributeRole role) { const bool roleIsOptional = false; return(GetFieldIndex(role, roleIsOptional)); }
public int GetFieldIndex(IObjectClass objectClass, string fieldName, AttributeRole role) { return(GetFieldIndex((ITable)objectClass, fieldName, role)); }