-
-
Save dcomartin/5b91960b708f00d4f8565f3cc4c8a760 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 abstract class Product(int id) | |
{ | |
public int Id { get; } = id; | |
} | |
public class Template(int id) : Product(id) { } | |
public class Ebook(int id) : Product(id) { } | |
public class OfflineCourse(int id) : Product(id) { } | |
public sealed class ProductHandler(ResourcesHelper resourcesHelper) | |
{ | |
public void DoStuff(Product product) | |
{ | |
if (product is Template || | |
product is Ebook|| | |
product is OfflineCourse) | |
{ | |
var fileName = resourcesHelper.GetDefaultDownloadFileName(product); | |
var downloadUrl = resourcesHelper.GetDownloadUrl(product); | |
} | |
} | |
} | |
public sealed class ResourcesHelper | |
{ | |
public string? GetDownloadUrl(Product product) | |
{ | |
if (product is Template || | |
product is Ebook|| | |
product is OfflineCourse) | |
{ | |
// some code to do this... | |
return "TODO: get the download URL"; | |
} | |
return null; | |
} | |
public string? GetDefaultDownloadFileName(Product product) | |
{ | |
if (product is Template || | |
product is Ebook|| | |
product is OfflineCourse) | |
{ | |
// some code to do this... | |
return "TODO: get the file name"; | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment