private void ImportKVA(string source, bool isFile) { XmlReader reader = null; try { bool relativeTrajectories; string kva = MetadataConverter.Convert(source, isFile, out relativeTrajectories); XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreComments = true; settings.IgnoreProcessingInstructions = true; settings.IgnoreWhitespace = true; settings.CloseInput = true; reader = isFile ? XmlReader.Create(kva, settings) : XmlReader.Create(new StringReader(kva), settings); Load(reader); if (relativeTrajectories) { metadata.FixRelativeTrajectories(); } } catch (Exception e) { log.Error("An error happened during the parsing of the KVA metadata"); log.Error(e); } finally { if (reader != null) { reader.Close(); } } }
/// <summary> /// Extract the referenced video file from the given KVA file. /// Used in the context of crash recovery. /// </summary> public static string ExtractFullPath(string source) { string kva = MetadataConverter.Convert(source, true); XmlDocument doc = new XmlDocument(); doc.Load(kva); XmlNode pathNode = doc.DocumentElement.SelectSingleNode("descendant::FullPath"); return(pathNode != null ? pathNode.InnerText : null); }
public static string ExtractFullPath(string source) { // Extract the referenced video file from the given KVA file. // Used in the context of crash recovery. string kva = MetadataConverter.Convert(source, true); XmlDocument doc = new XmlDocument(); doc.Load(kva); XmlNode pathNode = doc.DocumentElement.SelectSingleNode("descendant::FullPath"); return(pathNode != null ? pathNode.InnerText : null); }
public void Load(Metadata metadata, string source, bool isFile) { if (metadata == null) { throw new ArgumentNullException("metadata"); } if (string.IsNullOrEmpty(source)) { throw new ArgumentNullException("source"); } this.metadata = metadata; metadata.BeforeKVAImport(); string kva = MetadataConverter.Convert(source, isFile); XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreComments = true; settings.IgnoreProcessingInstructions = true; settings.IgnoreWhitespace = true; settings.CloseInput = true; XmlReader reader = null; try { reader = isFile ? XmlReader.Create(kva, settings) : XmlReader.Create(new StringReader(kva), settings); Load(reader); } catch (Exception e) { log.Error("An error happened during the parsing of the KVA metadata"); log.Error(e); } finally { if (reader != null) { reader.Close(); } } metadata.AfterKVAImport(); }