本文整理汇总了C#中IColumnInfo类的典型用法代码示例。如果您正苦于以下问题:C# IColumnInfo类的具体用法?C# IColumnInfo怎么用?C# IColumnInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IColumnInfo类属于命名空间,在下文中一共展示了IColumnInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvConvertFromCustom
public static byte[] InvConvertFromCustom(IColumnInfo type_info, object value)
{
CheckArgument<byte[]>(value);
return (byte[])value;
// CheckArgument<string>(value);
// return Encoding.UTF8.GetBytes((string)value);
}
示例2: InvConvertFromList
public static byte[] InvConvertFromList(IColumnInfo type_info, object value)
{
var listType = GetTypeFromList(type_info);
CheckArgument(listType, value);
var list_typecode = (type_info as ListColumnInfo).ValueTypeCode;
var list_typeinfo = (type_info as ListColumnInfo).ValueTypeInfo;
List<byte[]> bufs = new List<byte[]>();
int cnt = 0;
int bsize = 2;
foreach (var obj in (value as IEnumerable))
{
var buf = TypeInterpreter.InvCqlConvert(obj, list_typecode, list_typeinfo);
bufs.Add(buf);
bsize += buf.Length;
cnt++;
}
var ret = new byte[bsize];
var cntbuf = Int16ToBytes((short)cnt);
int idx = 0;
Buffer.BlockCopy(cntbuf, 0, ret, 0, 2);
idx += 2;
foreach (var buf in bufs)
{
Buffer.BlockCopy(buf, 0, ret, idx, buf.Length);
idx += buf.Length;
}
return ret;
}
示例3: ConvertFromInet
public static object ConvertFromInet(IColumnInfo type_info, byte[] value, Type cSharpType)
{
if (value.Length == 4 || value.Length == 16)
{
var ip = new IPAddress(value);
return new IPEndPoint(ip, 0);
}
else
{
var length = value[0];
IPAddress ip;
int port;
var buf = new byte[length];
if (length == 4)
{
Buffer.BlockCopy(value, 1, buf, 0, 4);
ip = new IPAddress(buf);
port = BytesToInt32(buf, 1 + 4);
return new IPEndPoint(ip, port);
}
else if (length == 16)
{
Buffer.BlockCopy(value, 1, buf, 0, 16);
ip = new IPAddress(buf);
port = BytesToInt32(buf, 1 + 16);
return new IPEndPoint(ip, port);
}
}
throw new DriverInternalError("Invalid lenght of Inet Addr");
}
示例4: InvConvertFromBoolean
public static byte[] InvConvertFromBoolean(IColumnInfo type_info, object value)
{
CheckArgument<bool>(value);
var buffer = new byte[1];
buffer[0] = ((bool)value) ? (byte)0x01 : (byte)0x00;
return buffer;
}
示例5: ColumnMap
public ColumnMap(MemberInfo member, IColumnInfo columnInfo)
{
FieldName = member.Name;
ColumnInfo = columnInfo;
// If the column name is not specified, the field name will be used.
if (string.IsNullOrEmpty(columnInfo.Name))
columnInfo.Name = member.Name;
FieldType = ReflectionHelper.GetMemberType(member);
Type paramNetType = FieldType;
Converter = MapRepository.Instance.GetConverter(FieldType);
if (Converter != null)
{
paramNetType = Converter.DbType;
}
DBType = MapRepository.Instance.DbTypeBuilder.GetDbType(paramNetType);
Getter = MapRepository.Instance.ReflectionStrategy.BuildGetter(member.DeclaringType, FieldName);
Setter = MapRepository.Instance.ReflectionStrategy.BuildSetter(member.DeclaringType, FieldName);
if (member.MemberType == MemberTypes.Property)
{
PropertyInfo pi = (PropertyInfo)member;
CanRead = pi.CanRead;
CanWrite = pi.CanWrite;
}
else if (member.MemberType == MemberTypes.Field)
{
CanRead = true;
CanWrite = true;
}
}
示例6: InvConvertFromDouble
public static byte[] InvConvertFromDouble(IColumnInfo type_info, object value)
{
CheckArgument<double>(value);
byte[] ret = BitConverter.GetBytes((double)value);
Array.Reverse(ret);
return ret;
}
示例7: ConvertFromTimestamp
public static object ConvertFromTimestamp(IColumnInfo type_info, byte[] value, Type cSharpType)
{
if (cSharpType == null || cSharpType.Equals(typeof(DateTimeOffset)))
return BytesToDateTimeOffset(value, 0);
else
return BytesToDateTimeOffset(value, 0).DateTime;
}
示例8: ConvertFromSet
public static object ConvertFromSet(IColumnInfo type_info, byte[] value, Type cSharpType)
{
if (type_info is SetColumnInfo)
{
var list_typecode = (type_info as SetColumnInfo).KeyTypeCode;
var list_typeinfo = (type_info as SetColumnInfo).KeyTypeInfo;
var value_type = TypeInterpreter.GetDefaultTypeFromCqlType(list_typecode, list_typeinfo);
int count = BytesToInt16(value, 0);
int idx = 2;
var openType = typeof(List<>);
var listType = openType.MakeGenericType(value_type);
object ret = Activator.CreateInstance(listType);
var addM = listType.GetMethod("Add");
for (int i = 0; i < count; i++)
{
var val_buf_len = BytesToInt16(value, idx);
idx += 2;
byte[] val_buf = new byte[val_buf_len];
Buffer.BlockCopy(value, idx, val_buf, 0, val_buf_len);
idx += val_buf_len;
addM.Invoke(ret, new object[] { TypeInterpreter.CqlConvert(val_buf, list_typecode, list_typeinfo) });
}
return ret;
}
throw new DriverInternalError("Invalid ColumnInfo");
}
示例9: ConfigurableColumn
public ConfigurableColumn(ListStoreMapping mapping, IColumnInfo info, DataColumn column)
{
this.Mapping = mapping;
this.ColumnInfo = info;
this.DataColumn = column;
this.Reorderable = true;
this.Resizable = true;
this.MinWidth = 20;
this.FixedWidth = 80;
this.Sizing = TreeViewColumnSizing.Fixed;
this.Clickable = true;
this.SortIndicator = false;
this.SortOrder = SortType.Ascending;
if(this.ColumnInfo != null)
{
this.Title = this.ColumnInfo.Caption;
this.Visible = this.ColumnInfo.Visible;
}
else if (this.DataColumn != null)
{
this.Title = this.DataColumn.Caption;
}
CreateCellRenderers();
this.Mapping.ColumnsStore.AddNode(this);
this.AddNotification(NotifyChange);
this.WidthAdjustment = new Adjustment(80, 20, 1000, 1, 2, 0);
this.WidthAdjustment.Changed += delegate {
this.FixedWidth = (int)(this.WidthAdjustment.Value);
};
}
示例10: CreateColumn
public ConfigurableColumn CreateColumn(IColumnInfo info, DataColumn column)
{
if(info != null)
{
if(!String.IsNullOrEmpty(info.FkReferenceTable))
return new LookupColumn(this, info, column);
}
if(column != null)
{
Type type = column.DataType;
if(type == typeof(DateTime))
return new DateTimeColumn(this, info, column);
else if(type == typeof(string))
return new StringColumn(this, info, column);
else if(type == typeof(bool))
return new CheckBoxColumn(this, info, column);
else if(type == typeof(Decimal))
return new DecimalColumn(this, info, column);
else if(type == typeof(Int64))
return new Int64Column(this, info, column);
else if(type == typeof(Int32))
return new Int64Column(this, info, column);
throw new Exception("Nelze vytvořit sloupeček pro typ " + type.ToString());
}
throw new Exception("Nelze vytvořit sloupeček");
}
示例11: InvConvertFromTimestamp
public static byte[] InvConvertFromTimestamp(IColumnInfo type_info, object value)
{
CheckArgument<DateTimeOffset, DateTime>(value);
if(value is DateTimeOffset)
return DateTimeOffsetToBytes((DateTimeOffset)value);
else
return DateTimeOffsetToBytes(new DateTimeOffset((DateTime)value));
}
示例12: InvConvertFromVarint
public static byte[] InvConvertFromVarint(IColumnInfo type_info, object value)
{
CheckArgument<BigInteger>(value);
var ret = ((BigInteger)value).ToByteArray();
Array.Reverse(ret);
return ret;
}
示例13: Deserialize
public override object Deserialize(ushort protocolVersion, byte[] buffer, int offset, int length, IColumnInfo typeInfo)
{
DeserializationCounter++;
if (_fixedValue)
{
return Utils.SliceBuffer(buffer, offset, length);
}
return base.Deserialize(protocolVersion, buffer, offset, length, typeInfo);
}
示例14: Deserialize
public object Deserialize(ushort protocolVersion, byte[] buffer, int offset, int length, IColumnInfo typeInfo)
{
buffer = Utils.SliceBuffer(buffer, offset, length);
if (_reverse)
{
Array.Reverse(buffer);
}
return _adapter.ConvertFrom(buffer);
}
示例15: BuildPropertieStr
public string BuildPropertieStr(IColumnInfo column)
{
StringBuilder sb = new StringBuilder();
bool hasvalue = false;
sb.AppendFormat("this.Property(t => t.{0})", column.PascalName);
if (column.Identity)
{
hasvalue = true;
sb.Append("\r\n ");
sb.Append(".HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)");
}
if (column.Computed)
{
hasvalue = true;
sb.Append("\r\n ");
sb.Append(".HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed)");
}
if (column.IsPrimaryKey)
{
if (!column.Identity)
{
hasvalue = true;
sb.Append("\r\n ");
sb.Append(".HasDatabaseGeneratedOption(DatabaseGeneratedOption.None)");
}
}
//if (!column.HasStringLength && column.Nullable)
// return string.Empty;
if (column.HasStringLength)
{
hasvalue = true;
sb.Append("\r\n ");
sb.AppendFormat(".HasMaxLength({0})", column.MaxLength);
}
if (!column.Nullable && !column.IsPrimaryKey && !column.Identity && !column.Computed)
{
hasvalue = true;
sb.Append("\r\n ");
sb.Append(".IsRequired()");
}
if(!hasvalue)
{
return string.Empty;
}
sb.Append(";");
return sb.ToString();
}