Показать сообщение отдельно
Старый 16.04.2014, 22:59   #10  
pedrozzz is offline
pedrozzz
Молодой, подающий надежды
Аватар для pedrozzz
MCBMSS
Лучший по профессии 2015
 
164 / 218 (8) ++++++
Регистрация: 18.02.2010
Адрес: Краснодар
Цитата:
Сообщение от udmitriy Посмотреть сообщение
а по подробнее (пример какой нибудь можно или ссылку)(не работал с этим еще) - как его из binary инициализировать
Как-то так:
X++:
    Binary                  binary1 = new Binary("string1");
    Binary                  binary2 = new Binary("string2");
    Binary                  binaryResult;
    
    System.Byte[]           byte1;
    System.Byte[]           byte2;
    System.Byte[]           byteResult;
    
    int                     len;
    System.IO.MemoryStream  memoryStream;
    ;
    
    try
    {
        memoryStream    = binary1.getMemoryStream();
        byte1           = memoryStream.ToArray();
        memoryStream.Close();
    
        memoryStream    = binary2.getMemoryStream();
        byte2           = memoryStream.ToArray();
        memoryStream.Close();
    
        len             = CLRInterop::getAnyTypeForObject(byte1.get_Length()) - 1;
        len            += CLRInterop::getAnyTypeForObject(byte2.get_Length()) - 1;
        
        byteResult      = new System.Byte[len]();
        
        memoryStream    = new System.IO.MemoryStream(byteResult);
        memoryStream.Write(byte1, 0, CLRInterop::getAnyTypeForObject(byte1.get_Length()) - 1);
        memoryStream.Write(byte2, 0, CLRInterop::getAnyTypeForObject(byte2.get_Length()) - 1);
        
        binaryResult    = Binary::constructFromMemoryStream(memoryStream);
        memoryStream.Close();
        
        info(binaryResult.string(0));
    }
    catch (Exception::CLRError)
    {
        error(AifUtil::getClrErrorMessage());
    }
еще результирующий массив можно так заполнить:
X++:
...
        byteResult      = new System.Byte[len]();
        
        System.Buffer::BlockCopy(
            byte1, 
            0, 
            byteResult, 
            0, 
            CLRInterop::getAnyTypeForObject(byte1.get_Length()) - 1);
        
        System.Buffer::BlockCopy(
            byte2, 
            0, 
            byteResult, 
            CLRInterop::getAnyTypeForObject(byte1.get_Length()) - 1, 
            CLRInterop::getAnyTypeForObject(byte2.get_Length()) - 1);
        
        memoryStream    = new System.IO.MemoryStream(byteResult);
...
На больших объемах не проверял, так что о производительности ничего не скажу. Стоит учесть, что в данном случае, при вычислении длины массива отнимается 1, т.к. строка завершается символом конца строки, который нас не интересует. Если оперируете данными файла, то скорее всего 1 вычитать не придется.
__________________
Кононов Пётр

Последний раз редактировалось pedrozzz; 16.04.2014 в 23:06.