Esempio n. 1
0
        public virtual void TestFailureWriteMetaBlocksWithSameName()
        {
            if (skip)
            {
                return;
            }
            writer.Append(Runtime.GetBytesForString("keyX"), Runtime.GetBytesForString
                              ("valueX"));
            // create a new metablock
            DataOutputStream outMeta = writer.PrepareMetaBlock("testX", Compression.Algorithm
                                                               .Gz.GetName());

            outMeta.Write(123);
            outMeta.Write(Runtime.GetBytesForString("foo"));
            outMeta.Close();
            // add the same metablock
            try
            {
                writer.PrepareMetaBlock("testX", Compression.Algorithm.Gz.GetName());
                NUnit.Framework.Assert.Fail("Cannot create metablocks with the same name.");
            }
            catch (Exception)
            {
            }
            // noop, expecting exceptions
            CloseOutput();
        }
Esempio n. 2
0
        public virtual void TestFailureWriteRecordAfterMetaBlock()
        {
            if (skip)
            {
                return;
            }
            // write a key/value first
            writer.Append(Runtime.GetBytesForString("keyX"), Runtime.GetBytesForString
                              ("valueX"));
            // create a new metablock
            DataOutputStream outMeta = writer.PrepareMetaBlock("testX", Compression.Algorithm
                                                               .Gz.GetName());

            outMeta.Write(123);
            outMeta.Write(Runtime.GetBytesForString("dummy"));
            outMeta.Close();
            // add more key/value
            try
            {
                writer.Append(Runtime.GetBytesForString("keyY"), Runtime.GetBytesForString
                                  ("valueY"));
                NUnit.Framework.Assert.Fail("Cannot add key/value after start adding meta blocks."
                                            );
            }
            catch (Exception)
            {
            }
            // noop, expecting exceptions
            CloseOutput();
        }
Esempio n. 3
0
 /// <summary>Write the given object to the stream.</summary>
 /// <remarks>
 /// Write the given object to the stream. If it is a Text or BytesWritable,
 /// write it directly. Otherwise, write it to a buffer and then write the
 /// length and data to the stream.
 /// </remarks>
 /// <param name="obj">the object to write</param>
 /// <exception cref="System.IO.IOException"/>
 private void WriteObject(Writable obj)
 {
     // For Text and BytesWritable, encode them directly, so that they end up
     // in C++ as the natural translations.
     if (obj is Text)
     {
         Text t   = (Text)obj;
         int  len = t.GetLength();
         WritableUtils.WriteVInt(stream, len);
         stream.Write(t.GetBytes(), 0, len);
     }
     else
     {
         if (obj is BytesWritable)
         {
             BytesWritable b   = (BytesWritable)obj;
             int           len = b.GetLength();
             WritableUtils.WriteVInt(stream, len);
             stream.Write(b.GetBytes(), 0, len);
         }
         else
         {
             buffer.Reset();
             obj.Write(buffer);
             int length = buffer.GetLength();
             WritableUtils.WriteVInt(stream, length);
             stream.Write(buffer.GetData(), 0, length);
         }
     }
 }
Esempio n. 4
0
        public virtual void TestFailureGetNonExistentMetaBlock()
        {
            if (skip)
            {
                return;
            }
            writer.Append(Runtime.GetBytesForString("keyX"), Runtime.GetBytesForString
                              ("valueX"));
            // create a new metablock
            DataOutputStream outMeta = writer.PrepareMetaBlock("testX", Compression.Algorithm
                                                               .Gz.GetName());

            outMeta.Write(123);
            outMeta.Write(Runtime.GetBytesForString("foo"));
            outMeta.Close();
            CloseOutput();
            TFile.Reader reader = new TFile.Reader(fs.Open(path), fs.GetFileStatus(path).GetLen
                                                       (), conf);
            DataInputStream mb = reader.GetMetaBlock("testX");

            NUnit.Framework.Assert.IsNotNull(mb);
            mb.Close();
            try
            {
                DataInputStream mbBad = reader.GetMetaBlock("testY");
                NUnit.Framework.Assert.Fail("Error on handling non-existent metablocks.");
            }
            catch (Exception)
            {
            }
            // noop, expecting exceptions
            reader.Close();
        }
Esempio n. 5
0
 /// <summary>
 /// Write the object to the byte stream, handling Text as a special
 /// case.
 /// </summary>
 /// <param name="o">the object to print</param>
 /// <exception cref="System.IO.IOException">if the write throws, we pass it on</exception>
 private void WriteObject(object o)
 {
     if (o is Text)
     {
         Text to = (Text)o;
         @out.Write(to.GetBytes(), 0, to.GetLength());
     }
     else
     {
         @out.Write(Sharpen.Runtime.GetBytesForString(o.ToString(), utf8));
     }
 }
Esempio n. 6
0
 /// <exception cref="System.IO.IOException"/>
 public override void Write(int b)
 {
     if (remain > 0)
     {
         @out.Write(b);
         --remain;
     }
     else
     {
         throw new IOException("Writing more bytes than advertised size.");
     }
 }
Esempio n. 7
0
        /// <exception cref="System.IO.IOException"/>
        private byte[] PrepareFakePacket(byte[] data, byte[] sums)
        {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            DataOutputStream      dos  = new DataOutputStream(baos);
            int          packetLen     = data.Length + sums.Length + Ints.Bytes;
            PacketHeader header        = new PacketHeader(packetLen, OffsetInBlock, Seqno, false, data
                                                          .Length, false);

            header.Write(dos);
            dos.Write(sums);
            dos.Write(data);
            dos.Flush();
            return(baos.ToByteArray());
        }
Esempio n. 8
0
        /// <summary>
        /// Writes controller data from the smartphone to the Raspberry
        /// or to the drone.
        /// </summary>
        /// <param name="args">Controller parameter (throttle, yaw, pitch, roll)</param>
        public void Write(params Int16[] args)
        {
            byte[] bytes = ConvertToByte(args);

            try
            {
                mDataOutputStream.Write(bytes);
                mDataOutputStream.Flush();
            }
            catch (Exception ex)
            {
                Log.Debug("BTSocketWriter", "Error while sending data");
            }
        }
Esempio n. 9
0
 /// <exception cref="System.IO.IOException"/>
 private int WritePrepWithUnkownLength(TFile.Writer writer, int start, int n)
 {
     for (int i = start; i < (start + n); i++)
     {
         DataOutputStream @out     = writer.PrepareAppendKey(-1);
         string           localKey = string.Format(localFormatter, i);
         @out.Write(Runtime.GetBytesForString(localKey));
         @out.Close();
         string value = "value" + localKey;
         @out = writer.PrepareAppendValue(-1);
         @out.Write(Runtime.GetBytesForString(value));
         @out.Close();
     }
     return(start + n);
 }
 /// <exception cref="System.IO.IOException"/>
 public virtual void WriteHistoryData(FileSystemApplicationHistoryStore.HistoryDataKey
                                      key, byte[] value)
 {
     lock (this)
     {
         DataOutputStream dos = null;
         try
         {
             dos = this.writer.PrepareAppendKey(-1);
             key.Write(dos);
         }
         finally
         {
             IOUtils.Cleanup(FileSystemApplicationHistoryStore.Log, dos);
         }
         try
         {
             dos = this.writer.PrepareAppendValue(value.Length);
             dos.Write(value);
         }
         finally
         {
             IOUtils.Cleanup(FileSystemApplicationHistoryStore.Log, dos);
         }
     }
 }
Esempio n. 11
0
 public byte[] toByteArray() {
     short datalen = 0;
     byte[] data = null;
     byte[] bytes = null;
     byte[] byteNew = null;
     try {
         if (dos != null) {
             dos.Flush();
             data = ms.ToArray();
             datalen = (short)data.Length;
             dos.Close();
         }
         MemoryStream bos1 = new MemoryStream(datalen + 3);
         DataOutputStream dos1 = new DataOutputStream(new BinaryWriterIns(bos1));
         dos1.WriteByteNew(command);
         dos1.WriteShort(datalen);
         if (datalen > 0) {
             dos1.Write(data);
         }
         bytes = bos1.ToArray();
         byteNew = new byte[bytes.Length - 3];
         int n = byteNew.Length;
         Array.Copy(bytes, 3, byteNew, 0, n);
         byteNew[0] = (byte)command;
         dos1.Close();
     }
     catch (IOException e) {
         Debug.Log(e.ToString());
     }
     return byteNew;
 }
Esempio n. 12
0
 /// <exception cref="System.IO.IOException"/>
 public static void SaveFloatArr(DataOutputStream rf, float[] arr)
 {
     rf.WriteInt(arr.Length);
     byte[] lArr = FloatArrToByteArr(arr);
     rf.Write(lArr);
     rf.Close();
 }
Esempio n. 13
0
 /// <exception cref="System.IO.IOException"/>
 public static void SaveDoubleArr(DataOutputStream rf, double[] arr)
 {
     rf.WriteInt(arr.Length);
     byte[] lArr = DoubleArrToByteArr(arr);
     rf.Write(lArr);
     rf.Close();
 }
Esempio n. 14
0
        // noop, expecting an exception
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestFailureAddValueWithoutKey()
        {
            if (skip)
            {
                return;
            }
            DataOutputStream outValue = null;

            try
            {
                outValue = writer.PrepareAppendValue(6);
                outValue.Write(Runtime.GetBytesForString("value0"));
                Fail("Cannot add a value without adding key first. ");
            }
            catch (Exception)
            {
            }
            finally
            {
                // noop, expecting an exception
                if (outValue != null)
                {
                    outValue.Close();
                }
            }
        }
Esempio n. 15
0
    public byte[] toByteArray()
    {
        short datalen = 0;

        byte[] data    = null;
        byte[] bytes   = null;
        byte[] byteNew = null;
        try {
            if (dos != null)
            {
                dos.Flush();
                data    = ms.ToArray();
                datalen = (short)data.Length;
                dos.Close();
            }
            MemoryStream     bos1 = new MemoryStream(datalen + 3);
            DataOutputStream dos1 = new DataOutputStream(new BinaryWriterIns(bos1));
            dos1.WriteByteNew(command);
            dos1.WriteShort(datalen);
            if (datalen > 0)
            {
                dos1.Write(data);
            }
            bytes   = bos1.ToArray();
            byteNew = new byte[bytes.Length - 3];
            int n = byteNew.Length;
            Array.Copy(bytes, 3, byteNew, 0, n);
            byteNew[0] = (byte)command;
            dos1.Close();
        }
        catch (IOException e) {
            Debug.Log(e.ToString());
        }
        return(byteNew);
    }
Esempio n. 16
0
        // noop, expecting an exception
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestFailureValueTooLong()
        {
            if (skip)
            {
                return;
            }
            DataOutputStream outKey = writer.PrepareAppendKey(4);

            outKey.Write(Runtime.GetBytesForString("key0"));
            outKey.Close();
            DataOutputStream outValue = writer.PrepareAppendValue(3);

            try
            {
                outValue.Write(Runtime.GetBytesForString("value0"));
                outValue.Close();
                NUnit.Framework.Assert.Fail("Value is longer than expected.");
            }
            catch (Exception)
            {
            }
            // noop, expecting an exception
            try
            {
                outKey.Close();
                outKey.Close();
            }
            catch (Exception)
            {
                NUnit.Framework.Assert.Fail("Second or more close() should have no effect.");
            }
        }
Esempio n. 17
0
        // noop, expecting an exception
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestFailureKeyTooShort()
        {
            if (skip)
            {
                return;
            }
            DataOutputStream outKey = writer.PrepareAppendKey(4);

            outKey.Write(Runtime.GetBytesForString("key0"));
            outKey.Close();
            DataOutputStream outValue = writer.PrepareAppendValue(15);

            try
            {
                outValue.Write(Runtime.GetBytesForString("value0"));
                outValue.Close();
                NUnit.Framework.Assert.Fail("Value is shorter than expected.");
            }
            catch (Exception)
            {
            }
            finally
            {
            }
        }
Esempio n. 18
0
        public byte[] ToByteArray()
        {
            MemoryStream     byteArrayOutputStream = new MemoryStream();
            DataOutputStream outputStream          = new DataOutputStream(byteArrayOutputStream);

            outputStream.Write(RtpHeader.ToByteArray());

            byte midiCommandHeader1 = 0;

            midiCommandHeader1 |= (byte)((B ? 1 : 0) << 7);
            midiCommandHeader1 |= (byte)((J ? 1 : 0) << 6);
            midiCommandHeader1 |= (byte)((Z ? 1 : 0) << 5);
            midiCommandHeader1 |= (byte)((P ? 1 : 0) << 4);

            if (B)
            {
                midiCommandHeader1 |= (byte)((Length & 0x0F00) >> 8);
                outputStream.WriteByte(midiCommandHeader1);
                outputStream.WriteByte(Length & 0x00FF);
            }
            else
            {
                midiCommandHeader1 |= (byte)Length;
                outputStream.WriteByte(midiCommandHeader1);
            }

            outputStream.Flush();
            return(byteArrayOutputStream.ToArray());
        }
Esempio n. 19
0
        // noop, expecting an exception
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestFailureCloseKeyStreamManyTimesInWriter()
        {
            if (skip)
            {
                return;
            }
            DataOutputStream outKey = writer.PrepareAppendKey(4);

            try
            {
                outKey.Write(Runtime.GetBytesForString("key0"));
                outKey.Close();
            }
            catch (Exception)
            {
            }
            finally
            {
                // noop, expecting an exception
                try
                {
                    outKey.Close();
                }
                catch (Exception)
                {
                }
            }
            // no-op
            outKey.Close();
            outKey.Close();
            Assert.True("Multiple close should have no effect.", true);
        }
Esempio n. 20
0
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestFailureKeyLongerThan64K_2()
        {
            if (skip)
            {
                return;
            }
            DataOutputStream outKey = writer.PrepareAppendKey(-1);

            try
            {
                byte[] buf  = new byte[K];
                Random rand = new Random();
                for (int nx = 0; nx < K + 2; nx++)
                {
                    rand.NextBytes(buf);
                    outKey.Write(buf);
                }
                outKey.Close();
                NUnit.Framework.Assert.Fail("Failed to handle key longer than 64K.");
            }
            catch (EOFException)
            {
            }
            finally
            {
                // noop, expecting exceptions
                try
                {
                    CloseOutput();
                }
                catch (Exception)
                {
                }
            }
        }
Esempio n. 21
0
        /// <exception cref="System.IO.IOException"/>
        private long WriteRecords(int count, bool knownKeyLength, bool knownValueLength,
                                  bool close)
        {
            long rawDataSize = 0;

            for (int nx = 0; nx < count; nx++)
            {
                string           key    = TestTFileByteArrays.ComposeSortedKey("key", nx);
                DataOutputStream outKey = writer.PrepareAppendKey(knownKeyLength ? key.Length : -
                                                                  1);
                outKey.Write(Runtime.GetBytesForString(key));
                outKey.Close();
                string           value    = "value" + nx;
                DataOutputStream outValue = writer.PrepareAppendValue(knownValueLength ? value.Length
                                         : -1);
                outValue.Write(Runtime.GetBytesForString(value));
                outValue.Close();
                rawDataSize += WritableUtils.GetVIntSize(Runtime.GetBytesForString(key).Length
                                                         ) + Runtime.GetBytesForString(key).Length + WritableUtils.GetVIntSize(Runtime.GetBytesForString
                                                                                                                                   (value).Length) + Runtime.GetBytesForString(value).Length;
            }
            if (close)
            {
                CloseOutput();
            }
            return(rawDataSize);
        }
Esempio n. 22
0
 /// <summary>Rewrite the last-read packet on the wire to the given output stream.</summary>
 /// <exception cref="System.IO.IOException"/>
 public virtual void MirrorPacketTo(DataOutputStream mirrorOut)
 {
     Preconditions.CheckState(!useDirectBuffers, "Currently only supported for non-direct buffers"
                              );
     mirrorOut.Write(((byte[])curPacketBuf.Array()), curPacketBuf.ArrayOffset(), curPacketBuf
                     .Remaining());
 }
Esempio n. 23
0
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestFailureOneEntryKnownLength()
        {
            if (skip)
            {
                return;
            }
            DataOutputStream outKey = writer.PrepareAppendKey(2);

            try
            {
                outKey.Write(Runtime.GetBytesForString("key0"));
                Fail("Specified key length mismatched the actual key length.");
            }
            catch (IOException)
            {
            }
            // noop, expecting an exception
            DataOutputStream outValue = null;

            try
            {
                outValue = writer.PrepareAppendValue(6);
                outValue.Write(Runtime.GetBytesForString("value0"));
            }
            catch (Exception)
            {
            }
        }
Esempio n. 24
0
        public override void ToOutputStream(DataOutputStream writer)
        {
            //Server to Client
            writer.WriteBoolean(DeckImage != null);
            if (DeckImage != null)
            {
                writer.WriteInt(ImageSlot);
                //Byte array lenght
                writer.WriteInt(DeckImage.InternalBitmap.Length);
                writer.Write(DeckImage.InternalBitmap);
                Json headerContent = new Json();


                headerContent.Font          = " ";
                headerContent.Size          = CurrentItem.Decksize;
                headerContent.Position      = CurrentItem.Deckposition;
                headerContent.Text          = CurrentItem.Deckname;
                headerContent.Color         = CurrentItem.Deckcolor;
                headerContent.Stroke_color  = CurrentItem.Stroke_color;
                headerContent.Stroke_dx     = CurrentItem.Stroke_dxtext;
                headerContent.Stroke_radius = CurrentItem.Stroke_radius;
                headerContent.Stroke_dy     = CurrentItem.Stroke_Dy;
                headerContent.IsStroke      = CurrentItem.IsStroke;
                headerContent.Isboldtext    = CurrentItem.Isboldtext;
                headerContent.Isnormaltext  = CurrentItem.Isnormaltext;
                headerContent.Isitalictext  = CurrentItem.Isitalictext;
                headerContent.Ishinttext    = CurrentItem.Ishinttext;
                string jsonString = JsonConvert.SerializeObject(headerContent, Formatting.None);

                writer.WriteUTF(jsonString);
            }
        }
Esempio n. 25
0
        private void WriteToDisk(System.IO.IsolatedStorage.IsolatedStorageFile iso, string storeFile)
        {
            DataOutputStream dos = FileUtils.WriteIsolatedStorageFileToDataInput(iso, storeFile);

            try
            {
                dos.WriteUTF(HEADER);
                dos.WriteInt(nextRecordId);
                dos.WriteInt(records.Count);
                for (int i = 0; i < records.Count; i++)
                {
                    RecordItem ri    = records[i];
                    long       pSize = ri.data.Length;
                    int        pId   = ri.id;
                    dos.WriteLong(pSize);
                    dos.WriteInt(pId);
                    dos.Write(ri.data);
                }
            }
            catch (Exception e)
            {
                throw new RecordStoreException("Error writing store to disk: " + e.StackTrace);
            }
            finally
            {
                if (dos != null)
                {
                    dos.Close();
                }
                dos = null;
            }
        }
Esempio n. 26
0
        /// <summary>Write the word vectors to an output stream.</summary>
        /// <remarks>
        /// Write the word vectors to an output stream. The stream is not closed on finishing
        /// the function.
        /// </remarks>
        /// <param name="out">The stream to write to.</param>
        /// <exception cref="System.IO.IOException">Thrown if the stream could not be written to.</exception>
        public virtual void Serialize(OutputStream @out)
        {
            DataOutputStream dataOut = new DataOutputStream(@out);
            // Write some length statistics
            int maxKeyLength = 0;
            int vectorLength = 0;

            foreach (KeyValuePair <string, float[]> entry in this)
            {
                maxKeyLength = Math.Max(Sharpen.Runtime.GetBytesForString(entry.Key).Length, maxKeyLength);
                vectorLength = entry.Value.Length;
            }
            VectorMap.Itype keyIntType = VectorMap.Itype.GetType(maxKeyLength);
            // Write the key length
            dataOut.WriteInt(maxKeyLength);
            // Write the vector dim
            dataOut.WriteInt(vectorLength);
            // Write the size of the dataset
            dataOut.WriteInt(this.Count);
            foreach (KeyValuePair <string, float[]> entry_1 in this)
            {
                // Write the length of the key
                byte[] key = Sharpen.Runtime.GetBytesForString(entry_1.Key);
                keyIntType.Write(dataOut, key.Length);
                dataOut.Write(key);
                // Write the vector
                foreach (float v in entry_1.Value)
                {
                    dataOut.WriteShort(FromFloat(v));
                }
            }
        }
        /// <exception cref="System.Exception"/>
        private void AddOrUpdateToken(TokenIdent ident, AbstractDelegationTokenSecretManager.DelegationTokenInformation
                                      info, bool isUpdate)
        {
            string nodeCreatePath = GetNodePath(ZkDtsmTokensRoot, DelegationTokenPrefix + ident
                                                .GetSequenceNumber());
            ByteArrayOutputStream tokenOs  = new ByteArrayOutputStream();
            DataOutputStream      tokenOut = new DataOutputStream(tokenOs);
            ByteArrayOutputStream seqOs    = new ByteArrayOutputStream();

            try
            {
                ident.Write(tokenOut);
                tokenOut.WriteLong(info.GetRenewDate());
                tokenOut.WriteInt(info.GetPassword().Length);
                tokenOut.Write(info.GetPassword());
                if (Log.IsDebugEnabled())
                {
                    Log.Debug((isUpdate ? "Updating " : "Storing ") + "ZKDTSMDelegationToken_" + ident
                              .GetSequenceNumber());
                }
                if (isUpdate)
                {
                    zkClient.SetData().ForPath(nodeCreatePath, tokenOs.ToByteArray()).SetVersion(-1);
                }
                else
                {
                    zkClient.Create().WithMode(CreateMode.Persistent).ForPath(nodeCreatePath, tokenOs
                                                                              .ToByteArray());
                }
            }
            finally
            {
                seqOs.Close();
            }
        }
        public byte[] ToByteArray()
        {
            MemoryStream     outputStream     = new MemoryStream();
            DataOutputStream dataOutputStream = new DataOutputStream(outputStream);

            dataOutputStream.Write(MIDI_COMMAND_HEADER1);
            dataOutputStream.Write(MIDI_COMMAND_HEADER2);
            dataOutputStream.Write(System.Text.Encoding.UTF8.GetBytes(CommandWord.ToString()));
            dataOutputStream.WriteInt(Ssrc);
            dataOutputStream.WriteByte(Count);
            dataOutputStream.Write(new byte[3]);
            dataOutputStream.WriteLong(Timestamp1);
            dataOutputStream.WriteLong(Timestamp2);
            dataOutputStream.WriteLong(Timestamp3);
            dataOutputStream.Flush();
            return(outputStream.ToArray());
        }
Esempio n. 29
0
        public byte[] ToByteArray()
        {
            MemoryStream     byteArrayOutputStream = new MemoryStream();
            DataOutputStream outputStream          = new DataOutputStream(byteArrayOutputStream);

            outputStream.Write(MidiCommandHeader.ToByteArray());

            bool first = true;

            foreach (MidiTimestampPair message in Messages)
            {
                if (first && !MidiCommandHeader.Z)
                {
                    first = false;
                }
                else
                {
                    int timestamp = message.Timestamp;
                    if (timestamp > 0x0FFFFFFF)
                    {
                        throw new IllegalArgumentException("Timestamp too big: " + timestamp);
                    }
                    if (timestamp > 0)
                    {
                        int numberOfSeptets =
                            (int)System.Math.Ceiling(Integer.BitCount(Integer.HighestOneBit(timestamp) * 2 - 1) / 7.0);
                        while (numberOfSeptets > 0)
                        {
                            outputStream.WriteByte(
                                (numberOfSeptets > 1 ? 0x80 : 0) | ((timestamp >> ((numberOfSeptets - 1) * 7)) & 0x7F));
                            numberOfSeptets--;
                        }
                    }
                    else
                    {
                        outputStream.WriteByte(0);
                    }
                }
                outputStream.Write(message.MidiMessage.Data);
            }

            outputStream.Flush();
            return(byteArrayOutputStream.ToArray());
        }
Esempio n. 30
0
 /// <exception cref="System.IO.IOException"/>
 private void WriteNumMetablocks(TFile.Writer writer, string compression, int n)
 {
     for (int i = 0; i < n; i++)
     {
         DataOutputStream dout = writer.PrepareMetaBlock("TfileMeta" + i, compression);
         byte[]           b    = Runtime.GetBytesForString(("something to test" + i));
         dout.Write(b);
         dout.Close();
     }
 }
Esempio n. 31
0
 public override byte[] ToByteArray()
 {
     try
     {
         MemoryStream     outputStream     = new MemoryStream();
         DataOutputStream dataOutputStream = new DataOutputStream(outputStream);
         dataOutputStream.Write(MIDI_COMMAND_HEADER1);
         dataOutputStream.Write(MIDI_COMMAND_HEADER2);
         dataOutputStream.Write(System.Text.Encoding.UTF8.GetBytes(CommandWord.ToString()));
         dataOutputStream.WriteInt(ProtocolVersion);
         dataOutputStream.WriteInt(InitiatorToken);
         dataOutputStream.WriteInt(Ssrc);
         dataOutputStream.Flush();
         return(outputStream.ToArray());
     }
     catch (Exception e)
     {
         throw new System.IO.IOException(e.Message);
     }
 }