Finished BackupServer and UpdateServer

This commit is contained in:
Brett Hewitson 2021-12-05 01:56:11 +10:00
parent 824daed0d1
commit 0f3c6e6be9
28 changed files with 618 additions and 216 deletions

View file

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
namespace ServerManagerTool.Lib
{
public class BranchSnapshot
{
private BranchSnapshot()
{
}
public string BranchName = string.Empty;
public string BranchPassword = string.Empty;
public static BranchSnapshot Create(ServerProfile profile)
{
return new BranchSnapshot
{
BranchName = profile.BranchName,
BranchPassword = profile.BranchPassword
};
}
public static BranchSnapshot Create(ServerProfileSnapshot profile)
{
return new BranchSnapshot
{
BranchName = profile.BranchName,
BranchPassword = profile.BranchPassword
};
}
}
public class BranchSnapshotComparer : IEqualityComparer<BranchSnapshot>
{
public bool Equals(BranchSnapshot x, BranchSnapshot y)
{
//Check whether the compared objects reference the same data.
if (Object.ReferenceEquals(x, y)) return true;
//Check whether any of the compared objects is null.
if (x is null || y is null)
return false;
//Check whether the snapshot' properties are equal.
return x.BranchName == y.BranchName;
}
public int GetHashCode(BranchSnapshot snapshot)
{
//Check whether the object is null
if (snapshot is null) return 0;
//Get hash code for the Name field if it is not null.
return snapshot.BranchName == null ? 0 : snapshot.BranchName.GetHashCode();
}
}
}