Example #1
0
 public static void AddColumnSet(ColumnSet columnSet)
 {
     css.AddOrUpdate(columnSet.GetHash(), (hash) => columnSet, (hash, ocs) => {
         throw new Exception();
     });
 }
Example #2
0
        public byte[] Serialize()
        {
            using (System.IO.MemoryStream MS = new System.IO.MemoryStream()) {
                using (System.IO.BinaryWriter bw = new System.IO.BinaryWriter(MS)) {
                    bw.Write(columnSet.GetHash());
                    bw.Write(FieldCount);
                    for (int n = 0; n != FieldCount; n++)
                    {
                        bw.Write((fields [n] == null) || (fields [n] == DBNull.Value));
                        if ((fields [n] != null) && (fields [n] != DBNull.Value))
                        {
                            //Console.WriteLine ("Column {0} contains {1}", n, values [n]);
                            switch (columnSet.Columns [n].TFQN)
                            {
                            case "System.Byte":
                                bw.Write((byte)fields [n]);
                                break;

                            case "System.Byte[]":
                                bw.Write(((byte[])fields [n]).Length);
                                bw.Write((byte[])fields [n]);
                                break;

                            case "System.SByte":
                                bw.Write((sbyte)fields [n]);
                                break;

                            case "System.Int16":
                                bw.Write((short)fields [n]);
                                break;

                            case "System.UInt16":
                                bw.Write((ushort)fields [n]);
                                break;

                            case "System.Int32":
                                bw.Write((int)fields [n]);
                                break;

                            case "System.UInt32":
                                bw.Write((uint)fields [n]);
                                break;

                            case "System.Int64":
                                bw.Write((long)fields [n]);
                                break;

                            case "System.UInt64":
                                bw.Write((ulong)fields [n]);
                                break;

                            case "System.Single":
                                bw.Write((float)fields [n]);
                                break;

                            case "System.Double":
                                bw.Write((double)fields [n]);
                                break;

                            case "System.String":
                                bw.Write((string)fields [n]);
                                break;

                            case "System.Char":
                                bw.Write((char)fields [n]);
                                break;

                            case "System.Guid":
                                bw.Write(((Guid)fields [n]).ToByteArray());
                                break;

                            case "System.Boolean":
                                bw.Write((bool)fields [n]);
                                break;

                            case "System.DateTime":
                                if (fields [n] is string)
                                {
                                    bw.Write((DateTime.Parse((string)fields [n])).Ticks);
                                }
                                else
                                {
                                    bw.Write(((DateTime)fields [n]).Ticks);
                                }
                                break;

                            default:
                                throw new Exception(string.Format("Type {0} is undefined", columnSet.Columns [n].TFQN));
                            }
                        }
                    }
                }
                return(MS.ToArray());
            }
        }
Example #3
0
File: Row.cs Project: vebin/BD2
 public static void AddColumnSet(ColumnSet columnSet)
 {
     css.AddOrUpdate (columnSet.GetHash (), (hash) => columnSet, (hash,ocs) => {
         throw new Exception ();
     });
 }