Пример #1
0
 public static void WriteUserInfo(DICOMBinaryWriter dw, UserInfo info)
 {
     dw.Write((byte) ItemType.USER_INFO);
     dw.WriteNullBytes(1); // Reserved Null Byte
     var body = new byte[0];
     using (var stream = new MemoryStream()) //Will write inner object to get length
     {
         using (var wr = new DICOMBinaryWriter(stream))
         {
             WriteMaxLength(wr, info.MaxPDULength);
             WriteImplementationClassUID(wr, info.ImplementationUID);
             WriteAsyncOperations(wr, info.AsynchronousOperations);
             WriteImplementationVersion(wr, info.ImplementationVersion);
             body = stream.ToArray();
         }
     }
     LengthWriter.WriteBigEndian(dw, body.Length, 2);
     dw.Write(body);
 }
Пример #2
0
 public static UserInfo ReadUserInfo(DICOMBinaryReader dr)
 {
     AssertItemType(dr, "User Info", ItemType.USER_INFO);
     var ui = new UserInfo();
     dr.Skip(2); // PDU ID and Reserved Null Byte
     int length = LengthReader.ReadBigEndian(dr, 2);
     if (length > 0)
     {
         ui.MaxPDULength = (int) ReadMaxLength(dr);
         ui.ImplementationUID = ReadImplementationClassUID(dr);
         if (dr.Peek(1)[0] == (byte) ItemType.ASYNCHRONOUS_OPERATIONS_WINDOW)
         {
             ui.AsynchronousOperations = ReadAsyncOperations(dr);
         }
         ui.ImplementationVersion = ReadImplementationVersion(dr);
     }
     return ui;
 }