in src/Microsoft.Azure.WebJobs.Host/Scale/HostConcurrencySnapshot.cs [33:81]
private bool Equals(HostConcurrencySnapshot other)
{
if (other == null)
{
return false;
}
if (object.ReferenceEquals(this, other))
{
return true;
}
if (NumberOfCores != other.NumberOfCores)
{
return false;
}
if ((FunctionSnapshots == null && other.FunctionSnapshots != null && other.FunctionSnapshots.Count > 0) ||
(FunctionSnapshots != null && FunctionSnapshots.Count > 0 && other.FunctionSnapshots == null))
{
return false;
}
if (FunctionSnapshots != null && other.FunctionSnapshots != null)
{
if (FunctionSnapshots.Count() != other.FunctionSnapshots.Count() ||
FunctionSnapshots.Keys.Union(other.FunctionSnapshots.Keys, StringComparer.OrdinalIgnoreCase).Count() != FunctionSnapshots.Count())
{
// function set aren't equal
return false;
}
// we know we have the same set of functions in both
// we now want to compare each function snapshot
foreach (var functionId in FunctionSnapshots.Keys)
{
if (other.FunctionSnapshots.TryGetValue(functionId, out FunctionConcurrencySnapshot otherFunctionSnapshot) &&
FunctionSnapshots.TryGetValue(functionId, out FunctionConcurrencySnapshot functionSnapshot) &&
!functionSnapshot.Equals(otherFunctionSnapshot))
{
return false;
}
}
}
// if none of the above checks have returned false, the snapshots
// are equal
return true;
}