Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created June 19, 2024 22:38
Show Gist options
  • Save dcomartin/eb65dc6acc741cf1a29ca16f9609971d to your computer and use it in GitHub Desktop.
Save dcomartin/eb65dc6acc741cf1a29ca16f9609971d to your computer and use it in GitHub Desktop.
public abstract class Product(int id, OfferingType type) { }
public class DownloadableProduct(int id, OfferingType type) : Product(id, type)
{
public Option<string> GetDefaultDownloadFileName()
{
return Option.Some("Some Value");
}
public Option<string> GetDownloadUrl()
{
return Option.Some("Some Value");
}
}
public sealed class ProductHandler()
{
public void DoStuff(DownloadableProduct 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