Hi Glenn,
I did some digging around. It's doable, however not immediately straight forward.
When serializing a tree, Sitecore invokes: Sitecore.Shell.Framework.Commands.Serialization.DumpTreeCommand. This is defined in /App_Config/Commands.config. When de-serializing, the equivalent .LoadTreeCommand is invoked.
What these commands do, is little more than invoking:
protected override void Dump(Item item)
{
Sitecore.Data.Serialization.Manager.DumpTree(item);
}
And unfortunately, to get to the functionality you need to override, it looks like you are going to have to 1) override the command in commands.config, and then create your own Serialization Manager (inheriting from Sitecore's).
I'm not entirely sure how easy this would be, since most of the methods in this class are static members. The method you would need to override/re-implement is this one:
public static void DumpItem(string path, Item item)
{
Assert.ArgumentNotNullOrEmpty(path, "path");
Assert.ArgumentNotNull(item, "item");
Directory.CreateDirectory(Path.GetDirectoryName(path));
using (new SecurityDisabler())
{
TextWriter writer = new StreamWriter(File.Create(path));
try
{
ItemSynchronization.WriteItem(item, writer);
}
catch
{
}
writer.Close();
}
}
The filename, as you can see, is based entirely on the Item's path. The assumption is, you could perhaps get away with something like .Replace("$", "!dollartoken!") and implement the reverse in your de-serializer.
Seems a lot of work though, unfortunately.