Skip to content

Commit

Permalink
Refactor projects
Browse files Browse the repository at this point in the history
  • Loading branch information
cjw1115 committed Jun 25, 2020
1 parent 351b5c1 commit 458c37c
Show file tree
Hide file tree
Showing 87 changed files with 3,172 additions and 3,055 deletions.
63 changes: 3 additions & 60 deletions AilianBT.Common/AilianBT.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,65 +17,6 @@
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
<PlatformTarget>ARM64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -124,13 +65,15 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\HttpService.cs" />
<Compile Include="Services\MusicService.cs" />
<Compile Include="ViewModelBase.cs" />
<EmbeddedResource Include="Properties\AilianBT.Common.rd.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.10</Version>
</PackageReference>
<PackageReference Include="MvvmLightLibs">
<Version>5.4.1.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Helpers\" />
Expand Down
8 changes: 3 additions & 5 deletions AilianBT.Common/Models/MusicModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using GalaSoft.MvvmLight;
using System;
using System.Runtime.Serialization;

namespace AilianBT.Common.Models
Expand All @@ -21,10 +22,7 @@ public class MusicModel: ViewModelBase
public bool HasCached
{
get=> _hasCached;
set
{
Set(ref _hasCached, value);
}
set => Set(ref _hasCached, value);
}

public override bool Equals(object obj)
Expand Down
44 changes: 23 additions & 21 deletions AilianBT.Common/Services/MusicService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using Windows.Data.Json;
Expand Down Expand Up @@ -44,6 +45,7 @@ public async Task<IList<MusicModel>> GetNetPlayList()
}
return musicList;
}

public async Task<IRandomAccessStream> GetMusicStream(Uri uri)
{
var newUri=uri.ToString() + "?date=" + DateTime.Now.Millisecond;
Expand Down Expand Up @@ -71,14 +73,16 @@ public async Task<bool> CahcheMusicAsync(IRandomAccessStream stream, MusicModel
System.Diagnostics.Debug.WriteLine($"Exception:{IOException.Message}");
#endif
}

if (folder == null)
{
folder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("CachedMusic");
}

Windows.Storage.StorageFile cacheFile = null;
try
{
cacheFile = await folder.CreateFileAsync(model.Title, Windows.Storage.CreationCollisionOption.FailIfExists);
cacheFile = await folder.CreateFileAsync(_createFileName(model), Windows.Storage.CreationCollisionOption.FailIfExists);
}
catch (ArgumentNullException)
{
Expand All @@ -105,6 +109,10 @@ public async Task<bool> CahcheMusicAsync(IRandomAccessStream stream, MusicModel
cacheFileStream?.Dispose();
}
}

/// <summary>
/// Get music stream from the local cache
/// </summary>
public async Task<IRandomAccessStream> GetCahchedMusicAsync(MusicModel model)
{
Windows.Storage.StorageFolder folder = null;
Expand All @@ -123,7 +131,7 @@ public async Task<IRandomAccessStream> GetCahchedMusicAsync(MusicModel model)
Windows.Storage.StorageFile cachedFile = null;
try
{
cachedFile = await folder.GetFileAsync(model.Title);
cachedFile = await folder.GetFileAsync(_createFileName(model));
return await cachedFile.OpenAsync(Windows.Storage.FileAccessMode.Read);
}
catch (System.Exception e)
Expand All @@ -135,25 +143,6 @@ public async Task<IRandomAccessStream> GetCahchedMusicAsync(MusicModel model)
}
}

private string CreateFileName(string arg)
{
if (string.IsNullOrEmpty(arg))
throw new ArgumentNullException("Filename should't be nullable");

string strAlgName = HashAlgorithmNames.Sha1;

HashAlgorithmProvider objAlgProv = HashAlgorithmProvider.OpenAlgorithm(strAlgName);

CryptographicHash objHash = objAlgProv.CreateHash();


IBuffer buffMsg1 = CryptographicBuffer.ConvertStringToBinary(arg.Trim(), BinaryStringEncoding.Utf16BE);
objHash.Append(buffMsg1);
IBuffer buffHash1 = objHash.GetValueAndReset();
string strHash1 = CryptographicBuffer.EncodeToBase64String(buffHash1);
return strHash1;
}

public async Task CheckCachedMusic(IList<MusicModel> models,System.Threading.SynchronizationContext context)
{
Windows.Storage.StorageFolder folder = null;
Expand Down Expand Up @@ -190,5 +179,18 @@ public async Task CheckCachedMusic(IList<MusicModel> models,System.Threading.Syn
}
}
}

private string _createFileName(MusicModel model)
{
byte[] sor = Encoding.UTF8.GetBytes(model.Title);
MD5 md5 = MD5.Create();
byte[] result = md5.ComputeHash(sor);
StringBuilder strbul = new StringBuilder(40);
for (int i = 0; i < result.Length; i++)
{
strbul.Append(result[i].ToString("x2"));
}
return strbul.ToString();
}
}
}
25 changes: 0 additions & 25 deletions AilianBT.Common/ViewModelBase.cs

This file was deleted.

63 changes: 5 additions & 58 deletions AilianBT.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,88 +5,35 @@ VisualStudioVersion = 16.0.30011.22
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AilianBT", "AilianBT\AilianBT.csproj", "{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MusicBackground", "MusicBackground\MusicBackground.csproj", "{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AilianBT.Common", "AilianBT.Common\AilianBT.Common.csproj", "{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Debug|Any CPU.ActiveCfg = Debug|x86
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Debug|Any CPU.Build.0 = Debug|x86
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Debug|Any CPU.Deploy.0 = Debug|x86
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Debug|ARM.ActiveCfg = Debug|ARM
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Debug|ARM.Build.0 = Debug|ARM
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Debug|ARM.Deploy.0 = Debug|ARM
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Debug|ARM64.ActiveCfg = Debug|x86
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Debug|ARM64.ActiveCfg = Debug|ARM64
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Debug|ARM64.Build.0 = Debug|ARM64
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Debug|x64.ActiveCfg = Debug|x64
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Debug|x64.Build.0 = Debug|x64
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Debug|x64.Deploy.0 = Debug|x64
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Debug|x86.ActiveCfg = Debug|x86
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Debug|x86.Build.0 = Debug|x86
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Debug|x86.Deploy.0 = Debug|x86
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Release|Any CPU.ActiveCfg = Release|x86
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Release|ARM.ActiveCfg = Release|ARM
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Release|ARM.Build.0 = Release|ARM
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Release|ARM.Deploy.0 = Release|ARM
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Release|ARM64.ActiveCfg = Release|x86
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Release|ARM64.ActiveCfg = Release|ARM64
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Release|ARM64.Build.0 = Release|ARM64
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Release|ARM64.Deploy.0 = Release|ARM64
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Release|x64.ActiveCfg = Release|x64
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Release|x64.Build.0 = Release|x64
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Release|x64.Deploy.0 = Release|x64
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Release|x86.ActiveCfg = Release|x86
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Release|x86.Build.0 = Release|x86
{6D8E9B75-9FEA-43A6-84FB-D66427E4E61C}.Release|x86.Deploy.0 = Release|x86
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Debug|ARM.ActiveCfg = Debug|ARM
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Debug|ARM.Build.0 = Debug|ARM
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Debug|ARM64.Build.0 = Debug|Any CPU
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Debug|x64.ActiveCfg = Debug|x64
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Debug|x64.Build.0 = Debug|x64
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Debug|x86.ActiveCfg = Debug|x86
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Debug|x86.Build.0 = Debug|x86
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Release|Any CPU.Build.0 = Release|Any CPU
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Release|ARM.ActiveCfg = Release|ARM
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Release|ARM.Build.0 = Release|ARM
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Release|ARM64.ActiveCfg = Release|Any CPU
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Release|ARM64.Build.0 = Release|Any CPU
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Release|x64.ActiveCfg = Release|x64
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Release|x64.Build.0 = Release|x64
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Release|x86.ActiveCfg = Release|x86
{A9DCFEEC-0E58-4203-BB01-F844D0B8C707}.Release|x86.Build.0 = Release|x86
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Debug|ARM.ActiveCfg = Debug|ARM
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Debug|ARM.Build.0 = Debug|ARM
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Debug|ARM64.ActiveCfg = Debug|ARM64
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Debug|ARM64.Build.0 = Debug|ARM64
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Debug|x64.ActiveCfg = Debug|x64
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Debug|x64.Build.0 = Debug|x64
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Debug|x86.ActiveCfg = Debug|x86
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Debug|x86.Build.0 = Debug|x86
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Release|Any CPU.Build.0 = Release|Any CPU
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Release|ARM.ActiveCfg = Release|ARM
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Release|ARM.Build.0 = Release|ARM
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Release|ARM64.ActiveCfg = Release|ARM64
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Release|ARM64.Build.0 = Release|ARM64
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Release|x64.ActiveCfg = Release|x64
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Release|x64.Build.0 = Release|x64
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Release|x86.ActiveCfg = Release|x86
{0891D52E-4D8E-4DA4-ACDD-F1F8C45CA898}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading

0 comments on commit 458c37c

Please sign in to comment.