/// <summary> /// /// </summary> /// <param name="name">A name for this tree, for your reference</param> /// <param name="globalRootItemPath">The 'global' path where this tree is rooted. For example, if this was '/sitecore/content', the root item in this tree would be 'content'</param> /// <param name="databaseName">Name of the database the items in this tree are from. This is for your reference and help when resolving this tree as a destination, and is not directly used.</param> /// <param name="physicalRootPath">The physical root path to write items in this tree to. Will be created if it does not exist.</param> /// <param name="formatter">The formatter to use when reading or writing items to disk</param> /// <param name="useDataCache">Whether to cache items read in memory for later rapid retrieval. Great for small trees, or if you have plenty of RAM. Bad for media trees :)</param> public SerializationFileSystemTree(string name, string globalRootItemPath, string databaseName, string physicalRootPath, ISerializationFormatter formatter, bool useDataCache) { Assert.ArgumentNotNullOrEmpty(globalRootItemPath, "globalRootItemPath"); Assert.ArgumentNotNullOrEmpty(databaseName, "databaseName"); Assert.ArgumentNotNullOrEmpty(physicalRootPath, "physicalRootPath"); Assert.ArgumentNotNull(formatter, "formatter"); Assert.IsTrue(globalRootItemPath.StartsWith("/"), "The global root item path must start with '/', e.g. '/sitecore' or '/sitecore/content'"); Assert.IsTrue(globalRootItemPath.Length > 1, "The global root item path cannot be '/' - there is no root item. You probably mean '/sitecore'."); _globalRootItemPath = globalRootItemPath.TrimEnd('/'); // enforce that the physical root path is filesystem-safe AssertValidPhysicalPath(physicalRootPath); _physicalRootPath = physicalRootPath; _formatter = formatter; _dataCache = new FsCache <IItemData>(useDataCache); Name = name; DatabaseName = databaseName; if (!Directory.Exists(_physicalRootPath)) { Directory.CreateDirectory(_physicalRootPath); } _treeWatcher = new TreeWatcher(_physicalRootPath, _formatter.FileExtension, HandleDataItemChanged); }