public static Field GetField( int col, string name, string desc, string type, string platform, string defaultValue, string validation) { FieldType fieldType = FieldTypeUtil.GetFieldType(type); Type resultType; if (fieldType != FieldType.None) { string fieldName = fieldType.ToString() + "Field"; resultType = AssemblyUtil.GetTypeByName(fieldName, true); } else { resultType = typeof(ErrorField); } return((Field)Activator.CreateInstance(resultType, col, name, desc, type, platform, defaultValue, validation)); }
public override object GetValue(Cell cell) { string cellContent = cell.GetContent(this); if (string.IsNullOrEmpty(cellContent)) { return(null); } else { Type valueRealyType = FieldTypeUtil.GetRealyType(ValueType); cellContent = cellContent.Substring(1, cellContent.Length - 2); string[] values = cellContent.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (values != null && values.Length > 0) { Array expanded = Array.CreateInstance(valueRealyType, values.Length); for (int i = 0; i < values.Length; ++i) { object valueObj = null; string valueStr = values[i]; if (valueRealyType == typeof(string)) { valueObj = valueStr; } else if (valueRealyType == typeof(int)) { valueObj = int.Parse(valueStr); } else if (valueRealyType == typeof(long)) { valueObj = long.Parse(valueStr); } else if (valueRealyType == typeof(float)) { valueObj = float.Parse(valueStr); } else if (valueRealyType == typeof(bool)) { valueObj = bool.Parse(valueStr); } expanded.SetValue(valueObj, i); } return(expanded); } return(null); } }
public ListField(int c, string n, string d, string t, string p, string v, string r) : base(c, n, d, t, p, v, r) { ValueType = FieldTypeUtil.GetListInnerType(t, out string refName); ValueRefName = refName; }