Beispiel #1
0
 /// <summary>
 /// Gets value that corresponds to specified key in <see cref="ShapefileRecordFields"/>
 /// </summary>
 /// <remarks>
 /// <para>Warning: Throws InvalidCastException if type of field value is incompatible with provided type</para>
 /// <code>Usage: ShapefileRecord.Fields.GetValue<DATA_TYPE>("DATA_COLUMN");</code>
 /// </remarks>
 public static double GetValue(this ShapefileRecordFields fields, string fieldKey)
 {
     if (!fields.ContainsKey(fieldKey))
     {
         DebugManager.LogWarning("Key not found in ShapefileRecordFields: " + fieldKey);
         return(double.NaN);
     }
     return((double)(fields[fieldKey]));
 }
Beispiel #2
0
 /// <summary>
 /// Gets value that corresponds to specified key in <see cref="ShapefileRecordFields"/>
 /// </summary>
 /// <remarks>
 /// <para>Warning: Throws InvalidCastException if type of field value is incompatible with provided type</para>
 /// <code>Usage: ShapefileRecord.Fields.GetValue<DATA_TYPE>("DATA_COLUMN");</code>
 /// </remarks>
 public static T GetValue <T>(this ShapefileRecordFields fields, string fieldKey)
 {
     if (!fields.ContainsKey(fieldKey))
     {
         DebugManager.LogWarning("Key not found in ShapefileRecordFields: " + fieldKey);
         return(default(T));
     }
     return((T)(fields[fieldKey]));
 }
Beispiel #3
0
 /// <summary>
 /// Checks if <see cref="ShapefileRecordFields"/> contains a key in its list of keys loaded from database (.dbf) file
 /// </summary>
 public static bool ContainsKey(this ShapefileRecordFields fields, string fieldKey)
 {
     foreach (var key in fields.Keys)
     {
         if (fieldKey == key)
         {
             return(true);
         }
     }
     return(false);
 }