コード例 #1
0
        public static IdentificationBlock Read(Mdf mdf, Stream stream)
        {
            var data = new byte[64];
            var read = stream.Read(data, 0, data.Length);

            if (read != data.Length)
            {
                throw new FormatException();
            }

            var block = new IdentificationBlock();

            block.Mdf                 = mdf;
            block.fileIdentifier      = Encoding.UTF8.GetString(data, 0, 8).Humanize();
            block.formatIdentifier    = Encoding.UTF8.GetString(data, 8, 8).Humanize();
            block.programIdentifier   = Encoding.UTF8.GetString(data, 16, 8).Humanize();
            block.ByteOrder           = (ByteOrder)BitConverter.ToUInt16(data, 24);
            block.FloatingPointFormat = (FloatingPointFormat)BitConverter.ToUInt16(data, 26);
            block.Version             = BitConverter.ToUInt16(data, 28);
            block.CodePage            = BitConverter.ToUInt16(data, 30);
            block.reserved1           = Encoding.UTF8.GetString(data, 32, 2).Humanize();
            block.reserved2           = Encoding.UTF8.GetString(data, 34, 30).Humanize();

            return(block);
        }
コード例 #2
0
        public Mdf(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            if (!stream.CanSeek)
            {
                throw new ArgumentException("stream");
            }

            Data          = stream;
            Data.Position = 0;
            IDBlock       = new IdentificationBlock(this);
            HDBlock       = new HeaderBlock(this);
        }
コード例 #3
0
        public static IdentificationBlock Create(Mdf mdf)
        {
            var block = new IdentificationBlock();

            block.Mdf                 = mdf;
            block.FileIdentifier      = "MDF     ";
            block.FormatIdentifier    = "3.30";
            block.ProgramIdentifier   = "";
            block.ByteOrder           = ByteOrder.LittleEndian;
            block.FloatingPointFormat = FloatingPointFormat.IEEE754;
            block.Version             = 330;
            block.CodePage            = 0;
            block.Reserved1           = "";
            block.Reserved2           = "";

            return(block);
        }
コード例 #4
0
ファイル: Mdf.cs プロジェクト: Meragon/ASAM-MDF.NET
        /// <summary>
        /// Read MDF from stream.
        /// </summary>
        /// <param name="stream"></param>
        public Mdf(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            if (!stream.CanSeek)
            {
                throw new ArgumentException("stream");
            }

            Data          = stream;
            Data.Position = 0;

            DataGroups = new DataGroupCollection(this);
            IDBlock    = IdentificationBlock.Read(this, stream);
            HDBlock    = HeaderBlock.Read(this, stream);
        }
コード例 #5
0
ファイル: Mdf.cs プロジェクト: Meragon/ASAM-MDF.NET
 public Mdf()
 {
     DataGroups = new DataGroupCollection(this);
     IDBlock    = IdentificationBlock.Create(this);
     HDBlock    = HeaderBlock.Create(this);
 }