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 extension = Path.GetExtension(source).ToLower(); if (extension == ".kva" || extension == ".xml") { ImportKVA(source, isFile); } else if (extension == ".srt") { MetadataImporterSRT.Import(metadata, source, isFile); } else if (source.EndsWith("_keypoints.json")) { MetadataImporterOpenPose.Import(metadata, source, isFile); } metadata.AfterKVAImport(); }
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(); }