public static string GetFieldTypeDisplayText(esriFieldType fieldType) { switch (fieldType) { case esriFieldType.esriFieldTypeSmallInteger: return("Short Integer"); case esriFieldType.esriFieldTypeInteger: return("Long Integer"); case esriFieldType.esriFieldTypeSingle: return("Float"); case esriFieldType.esriFieldTypeDouble: return("Double"); case esriFieldType.esriFieldTypeString: return("Text"); case esriFieldType.esriFieldTypeDate: return("Date"); case esriFieldType.esriFieldTypeOID: return("Object ID"); case esriFieldType.esriFieldTypeGeometry: return("Geometry"); case esriFieldType.esriFieldTypeBlob: return("Blob"); case esriFieldType.esriFieldTypeRaster: return("Raster"); case esriFieldType.esriFieldTypeGUID: return("Guid"); case esriFieldType.esriFieldTypeGlobalID: return("Global ID"); case esriFieldType.esriFieldTypeXML: return("XML"); default: return(fieldType.ToString()); } }
/// <summary> /// 获得字段类型的英文文字描述 /// </summary> /// <returns></returns> public static string GetFieldTypeDesciption(this esriFieldType eFieldType) { return(eFieldType.ToString().Replace("esriFieldType", "")); }
public static bool IsValidateValue(esriFieldType fieldType, string value, out string message) { if (string.IsNullOrEmpty(value)) { message = "is null or empty"; return false; } switch (fieldType) { case esriFieldType.esriFieldTypeSmallInteger: short valueTest1; bool validTest1 = short.TryParse(value, out valueTest1); message = validTest1 ? string.Empty : string.Format("is not a valid small integer"); return validTest1; case esriFieldType.esriFieldTypeInteger: int valueTest2; bool validTest2 = int.TryParse(value, out valueTest2); message = validTest2 ? string.Empty : string.Format("is not a valid integer"); return validTest2; case esriFieldType.esriFieldTypeSingle: float valueTest3; bool validTest3 = float.TryParse(value, out valueTest3); message = validTest3 ? string.Empty : string.Format("is not a valid single/float"); return validTest3; case esriFieldType.esriFieldTypeDouble: double valueTest4; bool validTest4 = double.TryParse(value, out valueTest4); message = validTest4 ? string.Empty : string.Format("is not a valid double"); return validTest4; case esriFieldType.esriFieldTypeString: message = string.Empty; return true; case esriFieldType.esriFieldTypeDate: CultureInfo cultureInfo = CultureInfo.CurrentCulture; DateTimeFormatInfo dateTimeFormatInfo = cultureInfo.DateTimeFormat; DateTime valueTest5; bool validTest5 = DateTime.TryParseExact(value, dateTimeFormatInfo.SortableDateTimePattern, cultureInfo, DateTimeStyles.None, out valueTest5); message = validTest5 ? string.Empty : string.Format("is not a valid date"); return validTest5; default: message = string.Format("field type [{0}] does not support default values", fieldType.ToString()); return false; } }
public static bool IsValidateValue(esriFieldType fieldType, string value, out string message) { if (string.IsNullOrEmpty(value)) { message = "is null or empty"; return(false); } switch (fieldType) { case esriFieldType.esriFieldTypeSmallInteger: short valueTest1; bool validTest1 = short.TryParse(value, out valueTest1); message = validTest1 ? string.Empty : string.Format("is not a valid small integer"); return(validTest1); case esriFieldType.esriFieldTypeInteger: int valueTest2; bool validTest2 = int.TryParse(value, out valueTest2); message = validTest2 ? string.Empty : string.Format("is not a valid integer"); return(validTest2); case esriFieldType.esriFieldTypeSingle: float valueTest3; bool validTest3 = float.TryParse(value, out valueTest3); message = validTest3 ? string.Empty : string.Format("is not a valid single/float"); return(validTest3); case esriFieldType.esriFieldTypeDouble: double valueTest4; bool validTest4 = double.TryParse(value, out valueTest4); message = validTest4 ? string.Empty : string.Format("is not a valid double"); return(validTest4); case esriFieldType.esriFieldTypeString: message = string.Empty; return(true); case esriFieldType.esriFieldTypeDate: CultureInfo cultureInfo = CultureInfo.CurrentCulture; DateTimeFormatInfo dateTimeFormatInfo = cultureInfo.DateTimeFormat; DateTime valueTest5; bool validTest5 = DateTime.TryParseExact(value, dateTimeFormatInfo.SortableDateTimePattern, cultureInfo, DateTimeStyles.None, out valueTest5); message = validTest5 ? string.Empty : string.Format("is not a valid date"); return(validTest5); default: message = string.Format("field type [{0}] does not support default values", fieldType.ToString()); return(false); } }
/// <summary> /// set feature of GeoJson File /// </summary> /// <param name="fieldName"></param> /// <param name="type"></param> /// <param name="feild"></param> private void setGeoJASONFeilds(string fieldName, esriFieldType type, Field_info feild) { try { feild.alias = feild.name = fieldName; feild.type = type.ToString(); } catch (Exception e) { Log.WriteLine("setGeoJASONFeilds: " + e.Message); } }
public static string ConvertToSimpleString(esriFieldType fieldType) { string typeString = fieldType.ToString().Substring(13); return(typeString); }