Created
December 2, 2016 06:38
-
-
Save ozw-sei/0e3c63e21a250321da16ecfe9143978b 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
public interface IOption<T>:IEquatable<IOption<T>>, IEquatable<T> | |
{ | |
bool IsDefined | |
{ | |
get; | |
} | |
// Something Method | |
// ... | |
} | |
public struct InternalOption<T> : IOption<T>{ | |
// 様々なInterfaceの実装 | |
public override bool Equals (object obj) | |
{ | |
var isOption = obj is IOption<T>; | |
if (isOption) | |
return Equals ((IOption<T>)obj); | |
if(obj is T){ | |
return Equals ((T)obj); | |
} | |
return false; | |
} | |
/// ↓みたいな関数の実装 | |
public static bool operator ==(IOption<T> option, T t){ | |
if (option == null || t == null) | |
return false; | |
return option.Equals (t); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment