public MatLabFileArrayWriter OpenArray(Type t, string varName, bool compress)
        {
            //first check if there is no array operation ongoing
            if (locker != null)
            {
                if(!locker.HasFinished())
                    throw new Exception("Previous array still open!");
                Flush();
            }

            //check whether type is not a string, as this is not supported for now
            if (t.Equals(typeof(String)))
                throw new NotImplementedException("Writing arrays of strings is not supported (as strings are arrays already)");

            MatLabFileArrayWriter arrayWriter;
            if(compress) {
                uncompressedStream = new MemoryStream();
                arrayWriter = new MatLabFileArrayWriter(t, varName, new BinaryWriter(uncompressedStream));
            } else {
                arrayWriter = new MatLabFileArrayWriter(t, varName, fileWriter);
            }

            locker = (IMatlabFileWriterLocker)arrayWriter;
            return arrayWriter;
        }
예제 #2
0
        public MatLabFileArrayWriter OpenArray(Type t, string varName, bool compress)
        {
            //first check if there is no array operation ongoing
            if (locker != null)
            {
                if (!locker.HasFinished())
                {
                    throw new Exception("Previous array still open!");
                }
                Flush();
            }

            //check whether type is not a string, as this is not supported for now
            if (t.Equals(typeof(String)))
            {
                throw new NotImplementedException("Writing arrays of strings is not supported (as strings are arrays already)");
            }

            MatLabFileArrayWriter arrayWriter;

            if (compress)
            {
                uncompressedStream = new MemoryStream();
                arrayWriter        = new MatLabFileArrayWriter(t, varName, new BinaryWriter(uncompressedStream));
            }
            else
            {
                arrayWriter = new MatLabFileArrayWriter(t, varName, fileWriter);
            }

            locker = (IMatlabFileWriterLocker)arrayWriter;
            return(arrayWriter);
        }