Avoid using Array.ConvertAll (doesn't exist on netcore)

This commit is contained in:
Garry Newman 2017-04-05 16:17:30 +01:00
parent 1e0f7a835c
commit 412d13cbbc
36 changed files with 41 additions and 6 deletions

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{
@ -51,7 +52,7 @@ public bool AddPromoItem( ref SteamInventoryResult_t pResultHandle /*SteamInvent
// bool
public bool AddPromoItems( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemDef_t[] pArrayItemDefs /*const SteamItemDef_t **/, uint unArrayLength /*uint32*/ )
{
return platform.ISteamInventory_AddPromoItems( ref pResultHandle.Value, Array.ConvertAll( pArrayItemDefs, p => p.Value ), unArrayLength );
return platform.ISteamInventory_AddPromoItems( ref pResultHandle.Value, pArrayItemDefs.Select( x => x.Value ).ToArray(), unArrayLength );
}
// bool
@ -81,13 +82,13 @@ public void DestroyResult( SteamInventoryResult_t resultHandle /*SteamInventoryR
// bool
public bool ExchangeItems( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemDef_t[] pArrayGenerate /*const SteamItemDef_t **/, uint[] punArrayGenerateQuantity /*const uint32 **/, uint unArrayGenerateLength /*uint32*/, SteamItemInstanceID_t[] pArrayDestroy /*const SteamItemInstanceID_t **/, uint[] punArrayDestroyQuantity /*const uint32 **/, uint unArrayDestroyLength /*uint32*/ )
{
return platform.ISteamInventory_ExchangeItems( ref pResultHandle.Value, Array.ConvertAll( pArrayGenerate, p => p.Value ), punArrayGenerateQuantity, unArrayGenerateLength, Array.ConvertAll( pArrayDestroy, p => p.Value ), punArrayDestroyQuantity, unArrayDestroyLength );
return platform.ISteamInventory_ExchangeItems( ref pResultHandle.Value, pArrayGenerate.Select( x => x.Value ).ToArray(), punArrayGenerateQuantity, unArrayGenerateLength, pArrayDestroy.Select( x => x.Value ).ToArray(), punArrayDestroyQuantity, unArrayDestroyLength );
}
// bool
public bool GenerateItems( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemDef_t[] pArrayItemDefs /*const SteamItemDef_t **/, uint[] punArrayQuantity /*const uint32 **/, uint unArrayLength /*uint32*/ )
{
return platform.ISteamInventory_GenerateItems( ref pResultHandle.Value, Array.ConvertAll( pArrayItemDefs, p => p.Value ), punArrayQuantity, unArrayLength );
return platform.ISteamInventory_GenerateItems( ref pResultHandle.Value, pArrayItemDefs.Select( x => x.Value ).ToArray(), punArrayQuantity, unArrayLength );
}
// bool
@ -151,7 +152,7 @@ public bool GetItemDefinitionProperty( SteamItemDef_t iDefinition /*SteamItemDef
// bool
public bool GetItemsByID( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemInstanceID_t[] pInstanceIDs /*const SteamItemInstanceID_t **/, uint unCountInstanceIDs /*uint32*/ )
{
return platform.ISteamInventory_GetItemsByID( ref pResultHandle.Value, Array.ConvertAll( pInstanceIDs, p => p.Value ), unCountInstanceIDs );
return platform.ISteamInventory_GetItemsByID( ref pResultHandle.Value, pInstanceIDs.Select( x => x.Value ).ToArray(), unCountInstanceIDs );
}
// bool
@ -223,7 +224,7 @@ public bool SerializeResult( SteamInventoryResult_t resultHandle /*SteamInventor
// bool
public bool TradeItems( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, CSteamID steamIDTradePartner /*class CSteamID*/, SteamItemInstanceID_t[] pArrayGive /*const SteamItemInstanceID_t **/, uint[] pArrayGiveQuantity /*const uint32 **/, uint nArrayGiveLength /*uint32*/, SteamItemInstanceID_t[] pArrayGet /*const SteamItemInstanceID_t **/, uint[] pArrayGetQuantity /*const uint32 **/, uint nArrayGetLength /*uint32*/ )
{
return platform.ISteamInventory_TradeItems( ref pResultHandle.Value, steamIDTradePartner.Value, Array.ConvertAll( pArrayGive, p => p.Value ), pArrayGiveQuantity, nArrayGiveLength, Array.ConvertAll( pArrayGet, p => p.Value ), pArrayGetQuantity, nArrayGetLength );
return platform.ISteamInventory_TradeItems( ref pResultHandle.Value, steamIDTradePartner.Value, pArrayGive.Select( x => x.Value ).ToArray(), pArrayGiveQuantity, nArrayGiveLength, pArrayGet.Select( x => x.Value ).ToArray(), pArrayGetQuantity, nArrayGetLength );
}
// bool

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
namespace SteamNative
{

View File

@ -185,7 +185,7 @@ internal string InteropVariable( bool AsRawValues )
{
if ( IsInputArray )
{
if ( AsRawValues && IsStruct ) return $"Array.ConvertAll( {Name}, p => p.Value )";
if ( AsRawValues && IsStruct ) return $"{Name}.Select( x => x.Value ).ToArray()";
return $"{Name}";
}

View File

@ -150,6 +150,7 @@ private void Header( string NamespaceName = "SteamNative" )
{
WriteLine( "using System;" );
WriteLine( "using System.Runtime.InteropServices;" );
WriteLine( "using System.Linq;" );
WriteLine();
StartBlock( "namespace " + NamespaceName );
}