Hi there,
I think this should go into the Feature Requests forum, but I wanted to discuss it here first. We have some custom code that inherits DynamicwebProvider. The use case is fairly simple: execute a stored procedure before and after the job runs. It's fairly simple to implement, but requires a lot of code duplication. For example, saving settings looks like this:
public override void SaveAsXml(XmlTextWriter xmlTextWriter)
{
// Ideally we wouldn't need to duplicate all of these here.. But the way it's written I don't see how.
xmlTextWriter.WriteElementString("RemoveMissingAfterImport", RemoveMissingAfterImport.ToString(CultureInfo.CurrentCulture));
xmlTextWriter.WriteElementString("DeactivateMissingProducts", DeactivateMissingProducts.ToString(CultureInfo.CurrentCulture));
xmlTextWriter.WriteElementString("DeleteIncomingItems", DeleteIncomingItems.ToString(CultureInfo.CurrentCulture));
xmlTextWriter.WriteElementString("SqlConnectionString", SqlConnectionString);
xmlTextWriter.WriteElementString("Shop", Shop);
xmlTextWriter.WriteElementString("UpdateSearchIndexAfterImport", IsFullProductIndexUpdate.ToString(CultureInfo.CurrentCulture));
xmlTextWriter.WriteElementString("ProductIndexUpdate", ProductIndexUpdate);
xmlTextWriter.WriteElementString("DeleteProductsAndGroupForSpecificLanguage", DeleteProductsAndGroupForSpecificLanguage.ToString(CultureInfo.CurrentCulture));
xmlTextWriter.WriteElementString("DefaultLanguage", DefaultLanguage);
xmlTextWriter.WriteElementString("RepositoriesIndexUpdate", RepositoriesIndexUpdate);
xmlTextWriter.WriteElementString("StoredProcBefore", StoredProcBefore);
xmlTextWriter.WriteElementString("StoredProcAfter", StoredProcAfter);
GetSchema().SaveAsXml(xmlTextWriter);
}
I really just care about the two lines that set the stored procedure names. All the other stuff is ideally hidden in the base class. Same goes for methods like Serialize and RunJob. I need to implement / duplicate quote a lot of stuff from the base class to make this all work.
Can we make this a bit more extensible and provide just a few hooks (LoadSettings, SaveSettings, OnBeforeRun, OnAfterRon or so) that I could tap into and leave everything else up to the base class?
Thanks!
Imar