-
-
Save dcomartin/613f72b80a3e8fe49cb388ee23a68683 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 class Product(int id, OfferingType type) | |
{ | |
public virtual Option<string> GetDownloadUrl() | |
{ | |
return Option.None<string>(); | |
} | |
public virtual Option<string> GetDefaultDownloadFileName() | |
{ | |
return Option.None<string>(); | |
} | |
} | |
public class DownloadProduct(int id, OfferingType type) : Product(id, type) | |
{ | |
public override Option<string> GetDefaultDownloadFileName() | |
{ | |
return Option.Some("Some Value"); | |
} | |
public override Option<string> GetDownloadUrl() | |
{ | |
return Option.Some("Some Value"); | |
} | |
} | |
public class Course(int id, OfferingType type) : Product(id, type) | |
{ | |
public override Option<string> GetDefaultDownloadFileName() | |
{ | |
return Option.None<string>(); | |
} | |
public override Option<string> GetDownloadUrl() | |
{ | |
return Option.None<string>(); | |
} | |
} | |
public sealed class ProductHandler() | |
{ | |
public void DoStuff(Product product) | |
{ | |
product.GetDefaultDownloadFileName().MatchSome( | |
filename => | |
{ | |
// Do something with the filename. | |
}); | |
product.GetDownloadUrl().MatchSome( | |
url => | |
{ | |
// Do something with the url | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment