I have multiple classes in a project that are exactly the same except for the name of the class. Basically, they represent glorified enums loaded at runtime from config files. The classes look like this:
public class ClassName : IEquatable<ClassName> {
public ClassName(string description) {
Description = description;
}
public override bool Equals(object obj) {
return obj != null &&
typeof(ClassName).IsAssignableFrom(obj.GetType()) &&
Equals((ClassName)obj);
}
public bool Equals(ClassName other) {
return other != null &&
Description.Equals(other.Description);
}
public override int GetHashCode() {
return Description.GetHashCode();
}
public override string ToString() {
return Description;
}
public string Description { get; private set; }
}
I see no reason to copy this file and change the class name multiple times. Surely there's a way I can just list what classes I want and have them automatically created for me. How?