コード例 #1
0
        private static AnnotationDatabase Open(string path, FileStream stream)
        {
            using (var binaryReader = new Util.BinaryReader(stream, Encoding.UTF8, true))
            {
                var signature = binaryReader.ReadBytes(Signature.Length);
                if (!signature.SequenceEqual(Signature))
                {
                    throw new DatabaseException("Incompatible Statsify Database format");
                }

                var major   = binaryReader.ReadByte();
                var minor   = binaryReader.ReadByte();
                var version = new Version(major, minor);
                if (version != new Version(1, 0))
                {
                    throw new DatabaseException("Incompatible Statsify Database version");
                }
            } // using

            return(new AnnotationDatabase(path));
        }
コード例 #2
0
        private static DatapointDatabase Open(string path, Stream stream, Func <DateTime> currentTimeProvider = null)
        {
            using (var binaryReader = new Util.BinaryReader(stream, Encoding.UTF8, true))
            {
                var signature = binaryReader.ReadBytes(Signature.Length);
                if (!signature.SequenceEqual(Signature))
                {
                    throw new DatabaseException("Incompatible Statsify Database format");
                }

                var major   = binaryReader.ReadByte();
                var minor   = binaryReader.ReadByte();
                var version = new Version(major, minor);
                if (version != new Version(1, 0))
                {
                    throw new DatabaseException("Incompatible Statsify Database version");
                }

                var dowsamplingMethod  = (DownsamplingMethod)binaryReader.ReadInt32();
                var downsamplingFactor = binaryReader.ReadSingle();
                var maxRetention       = binaryReader.ReadInt32();
                var archivesLength     = binaryReader.ReadInt32();

                var archives = new List <Archive>();

                for (var i = 0; i < archivesLength; ++i)
                {
                    var offset    = binaryReader.ReadInt32();
                    var precision = binaryReader.ReadInt32();
                    var history   = binaryReader.ReadInt32();

                    archives.Add(new Archive(offset, history * DatapointSize, new Retention(TimeSpan.FromSeconds(precision), history)));
                } // for

                return(new DatapointDatabase(path, downsamplingFactor, dowsamplingMethod, maxRetention, archives, currentTimeProvider));
            } // using
        }
コード例 #3
0
 public static PixelFormat Deserialize(Util.BinaryReader reader)
 {
     return(new PixelFormat()
     {
         BitsPerPixel = reader.ReadByte(),
         Depth = reader.ReadByte(),
         BigEndianFlag = reader.ReadByte(),
         TrueColorFlag = reader.ReadByte(),
         RedMax = reader.ReadUInt16(),
         GreenMax = reader.ReadUInt16(),
         BlueMax = reader.ReadUInt16(),
         RedShift = reader.ReadByte(),
         GreenShift = reader.ReadByte(),
         BlueShift = reader.ReadByte(),
         Padding = reader.ReadBytes(3),
     });
 }