Пример #1
0
        public static Hdf5File Open(Stream aFileStream)
        {
            Hdf5File
                fToReturn = new Hdf5File();

            if (!aFileStream.CanRead)
            {
                throw new Exception("Cannot Read Stream");
            }

            System.IO.FileStream
                fFileStream = aFileStream as FileStream;

            StreamInfo
                fStreamInfo;

            if (!ReferenceEquals(null, fFileStream))
            {
                fStreamInfo = new StreamInfo(
                    fFileStream.CanRead,
                    new FileInfo(fFileStream.Name));
            }
            else
            {
                fStreamInfo = new StreamInfo(
                    aFileStream.CanRead);
            }

            fToReturn.mrFileData.Register(
                fStreamInfo);

            fToReturn.mrFileData.Register <IStreamProvider, SimpleSingleStreamProvider>(
                new SimpleSingleStreamProvider(
                    aFileStream));

            fToReturn.Load();

            return(fToReturn);
        }
Пример #2
0
        public static Hdf5File Open(FileInfo aFileInfo)
        {
            Hdf5File
                fToReturn = new Hdf5File();
            StreamInfo
                fStreamInfo = new StreamInfo(aFileInfo);
            FileStream
                fFileStream = new FileStream(
                aFileInfo.FullName,
                FileMode.Open,
                fStreamInfo.CanWrite
                        ? FileAccess.ReadWrite
                        : FileAccess.Read,
                FileShare.Read);

            fToReturn.mrFileData.Register(fStreamInfo);
            fToReturn.mrFileData.Register <IStreamProvider, SimpleSingleStreamProvider>(
                new SimpleSingleStreamProvider(
                    fFileStream));

            fToReturn.Load();

            return(fToReturn);
        }