Im working on creating a method for logging data. I've repeated the same content multiple times, the only thing thats different is the type of object I'm using. (they both have the exact same properties. see code below:
public void LogContentLinkInformation() // here i would like the choice to pass in either a object type of "Product" or "Category"
{
for (int i = 0; i < categoryToUpdate?.CategoryImages?.Items.Count; i++)
{
_logger.LogDebug(nameof(ProcessFiles), $"Content Link Id: {categoryToUpdate?.CategoryImages?.Items[i].ContentLink.ID.ToString()}");
_logger.LogDebug(nameof(ProcessFiles), $"Provider Name: {categoryToUpdate?.CategoryImages?.Items[i].ContentLink.ProviderName}");
_logger.LogDebug(nameof(ProcessFiles), $"GetPublishedOrLatest: {categoryToUpdate?.CategoryImages?.Items[i].ContentLink.GetPublishedOrLatest.ToString()}");
}
}
As mentioned they both have the same properties, so to get the ContentlinkID, provider name and GetPublishedorLatest would all follow the same path for both the product and category object.
Any help would be appreciated.
Thanks