-
-
Save Nyconing/7ff7199f6b611ce3d86f89907716beef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Serializable] | |
public struct SubTypeText { | |
private object myValue; | |
public SubTypeText(DBNull aDBNull) { | |
this.myValue = (object) aDBNull; | |
} | |
public SubTypeText(string newValue) { | |
this.myValue = (object) newValue; | |
} | |
public bool HasValue { | |
get { return this.myValue != DBNull.Value; } | |
} | |
public override string ToString() { | |
return this.myValue.ToString(); | |
} | |
public static implicit operator SubTypeText(string newValue) { | |
return new SubTypeText(newValue); | |
} | |
public static implicit operator SubTypeText(DBNull aDBNull) { | |
return new SubTypeText(aDBNull); | |
} | |
public static implicit operator string(SubTypeText aDBType) { | |
return aDBType.myValue.ToString(); | |
} | |
public override bool Equals(object obj) { | |
if (this.HasValue) | |
return this.myValue.ToString() == obj.ToString(); | |
if (obj != null) | |
return obj == DBNull.Value; | |
return true; | |
} | |
public override int GetHashCode() { | |
return this.myValue.GetHashCode(); | |
} | |
public static bool operator ==(SubTypeText aDBType, DBNull aDBNull) { | |
return aDBType.myValue == aDBNull; | |
} | |
public static bool operator !=(SubTypeText aDBType, DBNull aDBNull) { | |
return aDBType.myValue != aDBNull; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment