converted int to Guid for Id properties
Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
07982a5697
commit
7cb75f8d5a
21
FirebaseKaraoke/Extensions.cs
Normal file
21
FirebaseKaraoke/Extensions.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FirebaseKaraoke.Extensions
|
||||
{
|
||||
public static class StringExtension
|
||||
{
|
||||
public static Guid ToGUID(this string input)
|
||||
{
|
||||
// Create a new instance of the MD5CryptoServiceProvider object.
|
||||
MD5 md5Hasher = MD5.Create();
|
||||
// Convert the input string to a byte array and compute the hash.
|
||||
byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));
|
||||
return new Guid(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using KaraokePlayer.Interfaces;
|
||||
using KaraokePlayer.Enums;
|
||||
using FireSharp.Interfaces;
|
||||
@ -13,7 +11,7 @@ namespace KaraokePlayer.Classes
|
||||
{
|
||||
public class FirebaseSong : ISong
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
public int Order { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Artist { get; set; }
|
||||
@ -24,6 +22,7 @@ namespace KaraokePlayer.Classes
|
||||
|
||||
public class FirebaseController : IController
|
||||
{
|
||||
public static Guid TestGuid = Guid.Parse("f1ec2c8a-6f11-4ac0-8b0e-e576d15f2759");
|
||||
private IFirebaseConfig config = new FirebaseConfig
|
||||
{
|
||||
AuthSecret = "wj0ERDFZqNSysTtIXcCgCr8Itahr6pJOBeqCjvDF",
|
||||
@ -48,7 +47,7 @@ namespace KaraokePlayer.Classes
|
||||
get { return string.Format("Controllers/{0}/CurrentSong", this.Id); }
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
public ISong CurrentSong { get; set; }
|
||||
public List<ISong> PlayQueue { get; set; }
|
||||
|
||||
@ -60,7 +59,7 @@ namespace KaraokePlayer.Classes
|
||||
}
|
||||
}
|
||||
|
||||
public FirebaseController(int clientId = 1, ControllerStateChangedEventHandler stateChanged = null, ControllerSongChangedEventHandler songChanged = null, ControllerPlayQueueChangedEventHandler playQueueChanged = null)
|
||||
public FirebaseController(Guid clientId, ControllerStateChangedEventHandler stateChanged, ControllerSongChangedEventHandler songChanged, ControllerPlayQueueChangedEventHandler playQueueChanged)
|
||||
{
|
||||
Id = clientId;
|
||||
_stateChanged = stateChanged;
|
||||
|
||||
@ -71,6 +71,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Enums.cs" />
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="FirebaseController.cs" />
|
||||
<Compile Include="Interfaces.cs" />
|
||||
<Compile Include="PlayerDelegates.cs" />
|
||||
|
||||
@ -9,7 +9,7 @@ namespace KaraokePlayer.Interfaces
|
||||
{
|
||||
public interface ISong
|
||||
{
|
||||
int Id { get; set; }
|
||||
Guid Id { get; set; }
|
||||
int Order { get; set; }
|
||||
string Title { get; set; }
|
||||
string Artist { get; set; }
|
||||
@ -20,7 +20,7 @@ namespace KaraokePlayer.Interfaces
|
||||
|
||||
public interface IController
|
||||
{
|
||||
int Id { get; set; }
|
||||
Guid Id { get; set; }
|
||||
ISong CurrentSong { get; set; }
|
||||
string State { get; set; }
|
||||
List<ISong> PlayQueue { get; set; }
|
||||
|
||||
@ -35,6 +35,7 @@ namespace KaraokePlayer
|
||||
karaokeMP4Player.Dock = DockStyle.Fill;
|
||||
|
||||
controller = new FirebaseController(
|
||||
clientId: FirebaseController.TestGuid,
|
||||
stateChanged: (args) =>
|
||||
{
|
||||
if (args.State == Enums.PlayerState.Play)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using KaraokePlayer.Classes;
|
||||
using KaraokePlayer.Enums;
|
||||
using KaraokePlayer.Interfaces;
|
||||
using FirebaseKaraoke.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -26,6 +27,7 @@ namespace TestSelector
|
||||
|
||||
InitializeComponent();
|
||||
controller = new FirebaseController(
|
||||
clientId: FirebaseController.TestGuid,
|
||||
stateChanged: (args) =>
|
||||
{
|
||||
if (args.State == KaraokePlayer.Enums.PlayerState.Play)
|
||||
@ -115,10 +117,10 @@ namespace TestSelector
|
||||
song.FileType = FileType.MP4;
|
||||
}
|
||||
song.Order = 1;
|
||||
song.Id = new Random().Next(0, 50000);
|
||||
song.Title = tag.Tag.Title;
|
||||
song.Artist = tag.Tag.Performers[0];
|
||||
song.Path = file.FullName.Replace(@"D:\KaraokeData\Karaoke\", @"Z:\");
|
||||
song.Id = song.Path.ToGUID();
|
||||
controller.AddSong(song);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user