using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnrealBuildTool
{
///
/// Represents a case-insensitive name in the filesystem
///
public class FileSystemName
{
///
/// Name as it should be displayed
///
public readonly string DisplayName;
///
/// The canonical form of the name
///
public readonly string CanonicalName;
///
/// Constructor
///
/// The display name
public FileSystemName(string DisplayName)
{
this.DisplayName = DisplayName;
CanonicalName = DisplayName.ToLowerInvariant();
}
///
/// Compares two filesystem object names for equality. Uses the canonical name representation, not the display name representation.
///
/// First object to compare.
/// Second object to compare.
/// True if the names represent the same object, false otherwise
public static bool operator ==(FileSystemName A, FileSystemName B)
{
if ((object)A == null)
{
return (object)B == null;
}
else
{
return (object)B != null && A.CanonicalName == B.CanonicalName;
}
}
///
/// Compares two filesystem object names for inequality. Uses the canonical name representation, not the display name representation.
///
/// First object to compare.
/// Second object to compare.
/// False if the names represent the same object, true otherwise
public static bool operator !=(FileSystemName A, FileSystemName B)
{
return !(A == B);
}
///
/// Compares against another object for equality.
///
/// other instance to compare.
/// True if the names represent the same object, false otherwise
public override bool Equals(object Obj)
{
return (Obj is FileSystemName) && ((FileSystemName)Obj) == this;
}
///
/// Returns a hash code for this object
///
/// Hash code for this object
public override int GetHashCode()
{
return base.GetHashCode();
}
///
/// Returns the display name
///
/// The display name
public override string ToString()
{
return DisplayName;
}
}
}