public override BPPData LoadData(IDataDescriptor dd) { var desc = dd as ThreeDInstanceDescriptor; if (desc == null) { throw new NotSupportedException("Cannot load data descriptor " + dd); } var instanceArchiveName = GetResourceName(FileName + @"\.zip"); using ( var instancesZipFile = new ZipArchive(GetType().Assembly.GetManifestResourceStream(instanceArchiveName), ZipArchiveMode.Read)) { var entry = instancesZipFile.GetEntry(desc.InstanceIdentifier); using (var stream = entry.Open()) { var parser = new ThreeDInstanceParser(); parser.Parse(stream); return(new BPPData() { Name = desc.Name, Description = desc.Description, BinShape = parser.Bin, Items = parser.Items.ToArray() }); } } }
public override BPPData ImportData(string path) { using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { var parser = new ThreeDInstanceParser(); parser.Parse(stream); return(new BPPData() { Name = Path.GetFileNameWithoutExtension(path), Description = "Imported instance from " + path, BinShape = parser.Bin, Items = parser.Items.ToArray() }); } }