Пример #1
0
        public override string GetString(byte[] data, String head)
        {
            IntPtr          ptr    = new IntPtr(BitConverter.ToInt64(data, 0));
            GCHandle        handle = GCHandle.FromIntPtr(ptr);
            DCMDataSequence sq     = (DCMDataSequence)handle.Target;

            return(sq.ToString(head + ">"));
        }
Пример #2
0
 public override T[] ReadValue <T>(byte[] data)
 {
     if (typeof(T) is DCMDataSequence)
     {
         IntPtr            ptr    = new IntPtr(BitConverter.ToInt64(data, 0));
         GCHandle          handle = GCHandle.FromIntPtr(ptr);
         DCMDataSequence[] sq     = new DCMDataSequence[1];
         sq[0] = (DCMDataSequence)handle.Target;
         return(sq as T[]);
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Пример #3
0
        /// <summary>
        /// SQ必须重写GetValue方法,因为传进来的参数length是由前边的Getlength方法获取的
        /// 而SQ可能取值FFFF
        /// </summary>
        /// <param name="data"></param>
        /// <param name="idx"></param>
        /// <param name="length">传入长度数值</param>
        /// <returns></returns>
        public override byte[] GetValue(byte[] data, ref uint idx, uint length)
        {
            uint            offset = idx;
            DCMDataSequence sq     = new DCMDataSequence(syntax);

            while (idx - offset < length)
            {
                DCMAbstractType item = syntax.Decode(data, ref idx);
                if (item.gtag == 0xfffe && item.etag == 0xe0dd)
                {
                    break;
                }
                else
                {
                    sq[0] = (DCMDataItem)item;
                }
            }
            GCHandle handle = GCHandle.Alloc(sq);
            IntPtr   ptr    = GCHandle.ToIntPtr(handle);

            return(BitConverter.GetBytes(ptr.ToInt64()));
        }