2017-05-31 88 views
0

誰能幫我把這段代碼轉換在.NET的核心:等效System.Data.Linq.Binary

private static string GetValueFromModelValue(object formValue) 
    { 
     //Test to determine if its binary data. If it is, we need to convert it to a base64 string. 
     Binary binaryValue = formValue as Binary; 
     if (binaryValue != null) 
     { 
      formValue = binaryValue.ToArray(); 
     } 

     //If the above conversion to an array worked, then the following will cast as a byte array and convert. 
     byte[] byteArrayValue = formValue as byte[]; 
     if (byteArrayValue != null) 
     { 
      formValue = Convert.ToBase64String(byteArrayValue); 
     } 

     return formValue.ToString(); 
    } 

回答

0

System.Data.Linq的類型是不具備的一個版本的.NET的核心和.NET標準(目前爲1.0 - 2.0)。

由於沒有呼叫者可在.NET核心一個Binary對象傳遞,則可以刪除該代碼或把它的預處理器內定義(本示例假定爲構建.NET核心1.1):

#if !NETCOREAPP1_1 
Binary binaryValue = … 
if (binaryValue != null) 
{ 
    … 
} 
#endif