![]() Renamed() is invoked when a targeted file is renamed.Deleted() is invoked when a targeted file is deleted.Created() is invoked when a new file is dropped in a directory or subdirectory being monitored, or when a targeted file is changed.The Created(), Deleted() and Renamed() methods aren’t really doing anything different from each other - they are all clearing the html cache for each instance returned by the GetSiteInfos() method, though I do want to point out that each of these methods are defined on the Sitecore.IO.FileWatcher base class and serve as event handlers for file system file actions: The SetMessages() method vets whether subclass returned these objects correctly, and sets them in private properties which are used in the Created(), Deleted() and Renamed() methods. Data returned by these methods are used when logging information or errors in the Sitecore log. The above class defines five abstract methods which subclasses must implement. If (collection = null || !collection.Any()) Protected virtual bool IsNullOrEmpty(IEnumerable collection) IEnumerable siteNames = Factory.GetSiteNames() Protected virtual IEnumerable GetSiteNames() SiteInfo siteInfo = Factory.GetSiteInfo(siteName) Protected virtual IEnumerable GetSiteInfos() Private string RenderingFileModifiedMessage ", siteInfo.Name), Owner) Public abstract class RenderingFileWatcher : FileWatcher I came up with the following class to serve as the base class for any FileWatcher that will monitor renderings that live on the file system: Likewise, the XslWatcher FileWatcher does the same thing for XSLT renderings but also clears the XSL cache along with the html cache. ascx) has been changed, deleted, renamed or added. The LayoutWatcher FileWatcher clears the html cache of all websites defined in Sitecore when it determines that a layout file (a.k.a. While digging through code of Sitecore.IO.FileWatcher subclasses this weekend, I noticed a lot of code similarities between the LayoutWatcher and XslWatcher classes, and thought it might be a good idea to abstract this logic out into a new base abstract class so that future FileWatchers which monitor other renderings on the file system can easily be added without having to write much logic.īefore I move forward on how I did this, let me explain what the LayoutWatcher FileWatcher does.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |