Added NS2.0 support to ZuneImpl

This commit is contained in:
Yoshi Askharoun
2022-07-13 20:43:25 -05:00
parent 90965fb41a
commit aac0f8cfc0
2 changed files with 57 additions and 4 deletions
+42
View File
@@ -0,0 +1,42 @@
using System;
using System.IO;
using System.Threading;
#if NETSTANDARD1_0_OR_GREATER
using System.Net.Http;
using System.Threading.Tasks;
#endif
namespace Microsoft.Zune
{
internal static class Extensions
{
#if NETSTANDARD2_0_OR_GREATER && !NET5_0_OR_GREATER
// FIXME: Blocking the executing thread is generally a bad idea.
// Executing some of these methods has a chance of
// deadlocking the app.
public static Stream ReadAsStream(this HttpContent content)
{
return content.ReadAsStreamAsync().Result;
}
public static HttpResponseMessage Send(this HttpClient client, HttpRequestMessage request)
{
return client.SendAsync(request).Result;
}
public static Task<Stream> GetStreamAsync(this HttpClient client, Uri uri, CancellationToken _)
{
return client.GetStreamAsync(uri);
}
#endif
#if NETSTANDARD && !NETSTANDARD2_1_OR_GREATER
public static Task CopyToAsync(this Stream source, Stream destination, CancellationToken _)
{
return source.CopyToAsync(destination);
}
#endif
}
}
+15 -4
View File
@@ -6,8 +6,9 @@
<OutputType>Library</OutputType>
<AssemblyName>ZuneImpl</AssemblyName>
<ApplicationVersion>4.8.0.0</ApplicationVersion>
<LangVersion>latest</LangVersion>
<TargetFrameworks>net35;net40;net6.0</TargetFrameworks>
<TargetFrameworks>net35;net40;netstandard2.0;net6.0</TargetFrameworks>
<Platforms>x64;x86</Platforms>
<RootNamespace>Microsoft.Zune</RootNamespace>
@@ -30,9 +31,19 @@
<ProjectReference Include="..\libs\MicrosoftIris\UIX\UIX.csproj" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<UseOpenZune>True</UseOpenZune>
</PropertyGroup>
<Choose>
<When Condition=" '$(TargetFramework)' == 'net6.0' ">
<PropertyGroup>
<UseOpenZune>True</UseOpenZune>
<DefineConstants>$(DefineConstants);NETSTANDARD2_1_OR_GREATER</DefineConstants>
</PropertyGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PropertyGroup>
<UseOpenZune>True</UseOpenZune>
</PropertyGroup>
</When>
</Choose>
<ItemGroup Condition="$(UseOpenZune)">
<PackageReference Include="StrixMusic.Sdk" Version="0.0.3-alpha" />