Example #1
0
 static byte[] ToBinary(ExpressionBlock expr)
 {
     using (var writer = PersistWriter.Create()) {
         writer.Write(expr);
         return(writer.ToArray());
     }
 }
Example #2
0
        public PersistWriter Writer(string name)
        {
            var path = Path.Combine(_basepath, name + "." + VariableExtension);
            var bw   = new BinaryWriter(File.Open(path, FileMode.Create));

            return(PersistWriter.Create(bw));
        }
Example #3
0
 // shorthand to serialise a heading
 public static byte[] ToBinary(DataHeading heading)
 {
     using (var writer = PersistWriter.Create()) {
         writer.Write(heading);
         return(writer.ToArray());
     }
 }
Example #4
0
 // shorthand to serialise a value of known type
 // must include type to know column order
 public static byte[] ToBinary(TypedValue value)
 {
     using (var writer = PersistWriter.Create()) {
         writer.WriteValue(value);
         return(writer.ToArray());
     }
 }
Example #5
0
 // Store typed value on memory stream, return byte array
 public byte[] Store(TypedValue value)
 {
     using (var writer = new BinaryWriter(new MemoryStream())) {
         var w = PersistWriter.Create(writer);
         w.Store(value);
         return((writer.BaseStream as MemoryStream).ToArray());
     }
 }
Example #6
0
        // Store typed value on file stream
        public void Store(string name, TypedValue value)
        {
            var path = Path.Combine(_basepath, name + "." + VariableExtension);

            Logger.WriteLine(3, "Storing {0} {1}", name, value);
            try {
                using (var writer = new BinaryWriter(File.Open(path, FileMode.Create))) {
                    var w = PersistWriter.Create(writer);
                    w.Store(value);
                }
            } catch (Exception ex) {
                throw ProgramError.Fatal("Storage", "cannot store '{0}' : {1}", name, ex.Message);
            }
        }
Example #7
0
 // persist a catalog entry
 public byte[] ToBinary()
 {
     using (var writer = PersistWriter.Create()) {
         writer.Write(Name);
         writer.Write((byte)Kind);
         writer.Write((byte)Flags);
         writer.Write(DataType);
         if (IsDatabase)
         {
             writer.WriteValue(RelationValue.Create(DataTableLocal.Create(Value.Heading)));
         }
         else if (Kind != EntryKinds.Type)
         {
             writer.WriteValue(Value);
         }
         return(writer.ToArray());
     }
 }
Example #8
0
 public static PersistWriter Create()
 {
     return(PersistWriter.Create(new BinaryWriter(new MemoryStream())));
 }