/// <summary> /// This is a minor optimization from the Utils/XElement serialization. Since this is a simple /// file the overhead of the reflection outweighs the few lines of code saved. /// We still save with Utils/ToXElement because it's easy, but we load it manually for speed. /// </summary> /// <param name="path">The path to the plugin cache file.</param> public static PluginCache Load(String path) { PluginCache cache = new PluginCache(); XElement root = XDocument.Load(path).Root; if (root != null) { foreach (var element in root.Descendants("PluginCacheEntry")) { var className = element.Element("ClassName"); var destinationPath = element.Element("DestinationPath"); var hash = element.Element("Hash"); var sourcePath = element.Element("SourcePath"); var stamp = element.Element("Stamp"); if (className != null && destinationPath != null && hash != null && sourcePath != null && stamp != null) { cache.Entries.Add(new PluginCacheEntry() { ClassName = className.Value, DestinationPath = destinationPath.Value, Hash = hash.Value, SourcePath = sourcePath.Value, Stamp = DateTime.Parse(stamp.Value) }); } } } return cache; }
/// <summary> /// This is a minor optimization from the Utils/XElement serialization. Since this is a simple /// file the overhead of the reflection outweighs the few lines of code saved. /// We still save with Utils/ToXElement because it's easy, but we load it manually for speed. /// </summary> /// <param name="path">The path to the plugin cache file.</param> public static PluginCache Load(String path) { PluginCache cache = new PluginCache(); XElement root = XDocument.Load(path).Root; if (root != null) { foreach (var element in root.Descendants("PluginCacheEntry")) { var className = element.Element("ClassName"); var destinationPath = element.Element("DestinationPath"); var hash = element.Element("Hash"); var sourcePath = element.Element("SourcePath"); var stamp = element.Element("Stamp"); if (className != null && destinationPath != null && hash != null && sourcePath != null && stamp != null) { cache.Entries.Add(new PluginCacheEntry() { ClassName = className.Value, DestinationPath = destinationPath.Value, Hash = hash.Value, SourcePath = sourcePath.Value, Stamp = DateTime.Parse(stamp.Value) }); } } } return(cache); }