65 lines
2.0 KiB
C#
65 lines
2.0 KiB
C#
using System;
|
|
|
|
namespace BCG {
|
|
/// <summary>
|
|
/// Resprsents information about a column schema, ie its ordinal, the type, the name and constant value or expression. where applicable
|
|
/// </summary>
|
|
[Serializable]
|
|
public class ColumnInfo : IComparable {
|
|
|
|
//the default column info does not cach values in a lookup table, therefore it is in group 0
|
|
public ColumnInfo(string colName, int colNo, Type colType, object colValue = null) {
|
|
myColName = colName;
|
|
myColNo = colNo;
|
|
myColType = colType;
|
|
myColValue = colValue;
|
|
}
|
|
|
|
public ColumnInfo(string col_name, int col_no, TypeCode type_code)
|
|
: this(col_name, col_no, BlueDataUtility.get_type(type_code)) {
|
|
}
|
|
|
|
public static bool isAllowedType(Type type) =>
|
|
type == typeof(int) ||
|
|
type == typeof(long) ||
|
|
type == typeof(double) ||
|
|
type == typeof(string) ||
|
|
type == typeof(DateTime);
|
|
|
|
public int CompareTo(object obj) {
|
|
int otherColNo = ((ColumnInfo)(obj)).colNo;
|
|
if (myColNo < otherColNo)
|
|
return -1;
|
|
else if (myColNo > otherColNo)
|
|
return 1;
|
|
return 0;
|
|
}
|
|
|
|
public override bool Equals(object obj) {
|
|
if (obj is ColumnInfo) {
|
|
ColumnInfo other = obj as ColumnInfo;
|
|
return (colNo == other.colNo) && (colName == other.colName) && (colType == other.colType);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override string ToString() {
|
|
return colName + " " + colNo + " " + colType;
|
|
}
|
|
|
|
|
|
// for backwards compatibility to allow build
|
|
public bool isConstant {get{return myColValue != null;}}
|
|
|
|
private int myColNo;
|
|
private string myColName;
|
|
private Type myColType;
|
|
private object myColValue;
|
|
|
|
public int colNo { get { return myColNo; } }
|
|
public string colName { get { return myColName; } }
|
|
public Type colType { get { return myColType; } }
|
|
public object colValue {get{return myColValue;}}
|
|
}
|
|
}
|