public HowToRestoreForm(MetaRecord record, RestorationMasterController controller) { InitializeComponent(); _record = record; _controller = controller; recoverItemTextBox.Text = _record.InitialTarget; this.Text = _record.InitialTarget; // locals restoreButton.Text = Translation.Current[438]; HowToRestoregroupBox.Text = Translation.Current[439]; toFolderRadioButton.Text = Translation.Current[440]; helpToolTip.SetToolTip(toOriginalLocationRadioButton, Translation.Current[441]); toOriginalLocationRadioButton.Text = Translation.Current[442]; helpToolTip.SetToolTip(to7zipArchiveRadioButton, Translation.Current[443]); to7zipArchiveRadioButton.Text = Translation.Current[444]; skipButton.Text = Translation.Current[445]; save7zipArchiveDialog.Filter = Translation.Current[446]; fbDialog.Description = Translation.Current[447]; this.Text = string.Format(Translation.Current[427], record.InitialTarget); restoreButton.Left = skipButton.Left - restoreButton.Width - 10; refreshRestoreButton(); refreshUiOnSelectedRestorationType(RestoreType.ToPointedFolder); }
ArchiveTask[] CreateArgsForCompressionAndMetaForImage(out Collection <MetaRecord> metarecords) { metarecords = new Collection <MetaRecord>(); Collection <CompressionItem> compressionItems = _task.FilesFoldersList; var parametersSet = new ArchiveTask[_task.FilesFoldersList.Count]; int syncIndex = 0; int itemIndex = 0; foreach (CompressionItem item in compressionItems) { // Compression item string tempFileName; do { tempFileName = Directories.TempFolder + @"\butil_tmp_" + syncIndex.ToString(CultureInfo.InvariantCulture) + ".7z"; syncIndex += 1; }while(!_temporaryFiles.TryRegisterNewName(tempFileName)); parametersSet[itemIndex] = _task.EnableEncryption ? new ArchiveTask(_options.ProcessPriority, tempFileName, item, _task.SecretPassword) : new ArchiveTask(_options.ProcessPriority, tempFileName, item); // Metainformation var record = new MetaRecord(item.IsFolder, item.Target); record.LinkedFile = tempFileName; metarecords.Add(record); itemIndex++; } return(parametersSet); }
public void NoFormula() { var data = "Name := Capital Ship Missile I"; var metarec = new MetaRecord(data.Split('\n')); Assert.AreEqual(0, metarec.Parameters.Count()); var recs = metarec.Instantiate(); Assert.AreEqual(1, recs.Count()); Assert.AreEqual("Capital Ship Missile I", recs.First().Get <string>("Name", null).Value); }
public void AddIfExist(XELement e, string property_name) { string t = e.tag.GetAttribute(property_name); if (t != "") { int pre = property_name.IndexOf(':'); if (pre > 0) { property_name = property_name.Substring(pre + 1); } var a = new MetaRecord(); a.name = property_name; a.value = t; refines.Add(a); } }
public void StaticFormula() { var data = @"Parameter Name := speed Parameter Minimum := 3 Parameter Maximum := 5 Parameter Name := warhead Parameter Maximum := 5 Name := ='Nuclear Missile ' + warhead.ToRomanNumeral() + ' S' + speed.ToString()"; var metarec = new MetaRecord(data.Split('\n')); Assert.AreEqual(2, metarec.Parameters.Count()); Assert.AreEqual(3, metarec.Parameters.First().Minimum); Assert.AreEqual(5, metarec.Parameters.First().Maximum); Assert.AreEqual(1, metarec.Parameters.Last().Minimum); Assert.AreEqual(5, metarec.Parameters.Last().Maximum); var recs = metarec.Instantiate(); Assert.AreEqual(15, recs.Count()); Assert.AreEqual(1, recs.Where(r => r.Get <string>("Name", null) == "Nuclear Missile III S4").Count()); }
public RestoreTaskInfo(MetaRecord record, RestoreType restoreType, string parameter) { _record = record; _parameter = parameter; _restoreType = restoreType; }
void ReadMeta3() { XFragment f = XFragment.FindFragment("metadata", OPF.text); List <MetaRecord> primary = new List <MetaRecord>(); foreach (var e in f.root.childs) { switch (e.tag.tagname) { case "dc:language": case "dc:identifier": { var t = new MetaRecord(e); primary.Add(t); } break; case "meta": { string name = e.tag.GetAttribute("name"); if (name != "") { var t = new MetaRecord(); t.name = name; t.value = e.tag.GetAttribute("content"); meta.Add(t); continue; } string refines = e.tag.GetAttribute("refines"); if (refines != "") { if (refines.StartsWith("#") && refines.Length > 1) { string id = refines.Substring(1); var t = new MetaRecord(e); t.name = e.tag.GetAttribute("property"); t.AddIfExist(e, "scheme"); foreach (var r in primary) { //要是refine在primary前面我可不管…… if (r.id == id) { r.refines.Add(t); break; } } continue; } } string property = e.tag.GetAttribute("property"); if (property != "") { var t = new MetaRecord(e); t.name = property; meta.Add(t); continue; } } break; default: { var t = new MetaRecord(e); t.AddIfExist(e, "xml:lang"); t.AddIfExist(e, "dir"); primary.Add(t); } break; } } foreach (var a in primary) { switch (a.name) { case "dc:title": dc_titles.Add(a); break; case "dc:creator": dc_creators.Add(a); break; case "dc:identifier": dc_identifier.Add(a); break; case "dc:language": dc_language.Add(a); break; default: others.Add(a); break; } } foreach (var a in dc_identifier) { if (idref == a.id) { uniqueIdentifier = a; break; } } foreach (var a in manifest) { switch (a.Value.properties) { case "nav": _toc = a.Value; break; case "cover-image": cover_img = a.Value.href; break; } } if (_toc == null) { _toc = spine.toc; } //check //if (dc_titles.Count == 0 || dc_identifier.Count == 0 || dc_language.Count == 0) { throw new EpubErrorException("Lack of some metadata."); } }
void ReadMeta2() { XFragment f = XFragment.FindFragment("metadata", OPF.text); foreach (var e in f.root.childs) { switch (e.tag.tagname) { case "dc:title": { var t = new MetaRecord(e); t.AddIfExist(e, "opf:file-as"); dc_titles.Add(t); } break; case "dc:creator": { var t = new MetaRecord(e); t.AddIfExist(e, "opf:file-as"); t.AddIfExist(e, "opf:role"); dc_creators.Add(t); } break; case "dc:language": { var t = new MetaRecord(e); dc_language.Add(t); } break; case "dc:identifier": { var t = new MetaRecord(e); t.AddIfExist(e, "opf:scheme"); dc_identifier.Add(t); } break; case "dc:contributor": { var t = new MetaRecord(e); t.AddIfExist(e, "opf:file-as"); t.AddIfExist(e, "opf:role"); others.Add(t); } break; case "dc:date": { var t = new MetaRecord(e); t.AddIfExist(e, "opf:event"); others.Add(t); } break; case "meta": { var t = new MetaRecord(); t.name = e.tag.GetAttribute("name"); t.value = e.tag.GetAttribute("content"); meta.Add(t); } break; default: { var t = new MetaRecord(e); others.Add(t); } break; } } foreach (var a in meta) { if (a.name == "cover") { string id = a.value; if (manifest.ContainsKey(id)) { cover_img = manifest[id].href; } break; } } _toc = spine.toc; }
void ReadMeta3() { var f = packageDocument.GetElementsByTagName("metadata")[0] as XmlElement; List <MetaRecord> primary = new List <MetaRecord>(); foreach (XmlNode node in f.ChildNodes) { if (node.NodeType != XmlNodeType.Element) { continue; } var e = (XmlElement)node; string n = e.Name; switch (n) { case "dc:language": case "dc:identifier": { var t = new MetaRecord(e); primary.Add(t); } break; case "meta": { string name = e.GetAttribute("name"); if (name != "") { var t = new MetaRecord(); t.name = name; t.value = e.GetAttribute("content"); meta.Add(t); continue; } string refines = e.GetAttribute("refines"); if (refines != "") { if (refines.StartsWith("#") && refines.Length > 1) { string id = refines.Substring(1); var t = new MetaRecord(e); t.name = e.GetAttribute("property"); t.AddIfExist(e, "scheme"); foreach (var r in primary) { //要是refine在primary前面我可不管…… if (r.id == id) { r.refines.Add(t); break; } } continue; } } string property = e.GetAttribute("property"); if (property != "") { var t = new MetaRecord(e); t.name = property; meta.Add(t); continue; } } break; default: { var t = new MetaRecord(e); t.AddIfExist(e, "xml:lang"); t.AddIfExist(e, "dir"); primary.Add(t); } break; } } foreach (var a in primary) { switch (a.name) { case "dc:title": titleRecords.Add(a); break; case "dc:creator": creatorRecords.Add(a); break; case "dc:identifier": identifierRecords.Add(a); break; case "dc:language": languageRecords.Add(a); break; default: otherRecords.Add(a); break; } } foreach (var a in identifierRecords) { if (idref == a.id) { uniqueIdentifier = a; break; } } foreach (var a in manifest) { switch (a.Value.properties) { case "nav": _toc = a.Value; break; case "cover-image": coverImage = a.Value; break; } } if (_toc == null) { _toc = spine.toc; } //check //if (dc_titles.Count == 0 || dc_identifier.Count == 0 || dc_language.Count == 0) { throw new EpubErrorException("Lack of some metadata."); } }
void ReadMeta2() { var f = packageDocument.GetElementsByTagName("metadata")[0] as XmlElement; foreach (XmlNode node in f.ChildNodes) { if (node.NodeType != XmlNodeType.Element) { continue; } var e = (XmlElement)node; string n = e.Name; switch (n) { case "dc:title": { var t = new MetaRecord(e); t.AddIfExist(e, "opf:file-as"); titleRecords.Add(t); } break; case "dc:creator": { var t = new MetaRecord(e); t.AddIfExist(e, "opf:file-as"); t.AddIfExist(e, "opf:role"); creatorRecords.Add(t); } break; case "dc:language": { var t = new MetaRecord(e); languageRecords.Add(t); } break; case "dc:identifier": { var t = new MetaRecord(e); t.AddIfExist(e, "opf:scheme"); identifierRecords.Add(t); } break; case "dc:contributor": { var t = new MetaRecord(e); t.AddIfExist(e, "opf:file-as"); t.AddIfExist(e, "opf:role"); otherRecords.Add(t); } break; case "dc:date": { var t = new MetaRecord(e); t.AddIfExist(e, "opf:event"); otherRecords.Add(t); } break; case "meta": { var t = new MetaRecord(); t.name = e.GetAttribute("name"); t.value = e.GetAttribute("content"); meta.Add(t); } break; default: { var t = new MetaRecord(e); otherRecords.Add(t); } break; } } foreach (var a in meta) { if (a.name == "cover") { string id = a.value; if (manifest.ContainsKey(id)) { coverImage = manifest[id]; } break; } } foreach (var a in identifierRecords) { if (idref == a.id) { uniqueIdentifier = a; break; } } _toc = spine.toc; }