public AwardEntryViewModel(AwardEntry model, JamOverviewViewModel jamOverview) : base(model) { Candidates = ListCandidates(jamOverview); var currentCandidate = Candidates.Single(candidate => candidate.Entry?.Model.Id == model.JamEntry?.Id); EntryProperty = MutableProperty.Create(this, nameof(Entry), currentCandidate); }
public void TestWriteSimplePropertySet() { String AUTHOR = "Rainer Klute"; String TITLE = "Test Document"; FileInfo fi = TempFile.CreateTempFile(POI_FS, ".doc"); FileStream file = new FileStream(fi.FullName, FileMode.Open, FileAccess.ReadWrite); FileStream out1 = file; POIFSFileSystem poiFs = new POIFSFileSystem(); MutablePropertySet ps = new MutablePropertySet(); MutableSection si = new MutableSection(); si.SetFormatID(SectionIDMap.SUMMARY_INFORMATION_ID); ps.Sections[0] = si; MutableProperty p = new MutableProperty(); p.ID = PropertyIDMap.PID_AUTHOR; p.Type = Variant.VT_LPWSTR; p.Value = AUTHOR; si.SetProperty(p); si.SetProperty(PropertyIDMap.PID_TITLE, Variant.VT_LPSTR, TITLE); poiFs.CreateDocument(ps.ToInputStream(), SummaryInformation.DEFAULT_STREAM_NAME); poiFs.WriteFileSystem(out1); poiFs.Close(); //out1.Close(); file.Position = 0; POIFSReader reader1 = new POIFSReader(); //reader1.StreamReaded += new POIFSReaderEventHandler(reader1_StreamReaded); POIFSReaderListener1 psl = new POIFSReaderListener1(); reader1.RegisterListener(psl); reader1.Read(file); Assert.IsNotNull(psa[0]); Assert.IsTrue(psa[0].IsSummaryInformation); Section s = (Section)(psa[0].Sections[0]); Object p1 = s.GetProperty(PropertyIDMap.PID_AUTHOR); Object p2 = s.GetProperty(PropertyIDMap.PID_TITLE); Assert.AreEqual(AUTHOR, p1); Assert.AreEqual(TITLE, p2); file.Close(); try { File.Delete(fi.FullName); } catch { } }
public RankingOverviewViewModel(RankingOverview model) : base(model) { RankedEntries = new RankedEntriesListViewModel(model.RankedEntries, rankingOverview: this); UnrankedEntries = new UnrankedEntriesListViewModel(model.UnrankedEntries, rankingOverview: this); SelectedEntryProperty = MutableProperty.Create(this, nameof(SelectedEntry), initialValue: (RankingEntryViewModel?)null) .WithDependingProperty(RankedEntries, nameof(RankedEntries.SelectedEntry)) .WithDependingProperty(UnrankedEntries, nameof(UnrankedEntries.SelectedEntry)); GetNextEntryCommand = new SimpleCommand(GetNextEntry); }
public RankingEntryViewModel(RankingEntry model) : base(model) { JamEntry = new JamEntryViewModel(model.JamEntry); RankProperty = MutableProperty.Create(this, nameof(Rank), (int?)null) .WithDependingProperty(nameof(IsRanked)); Ratings = model.Ratings.Select(RatingViewModel.Create).ToList(); CommentProperty = WrapperProperty.Create(this, nameof(Comment), vm => vm.Model.Comment, (vm, value) => vm.Model.Comment = value); }
public void TestUnicodeWrite8Bit() { String TITLE = "This is a sample title"; MutablePropertySet mps = new MutablePropertySet(); MutableSection ms = (MutableSection)mps.Sections[0]; ms.SetFormatID(SectionIDMap.SUMMARY_INFORMATION_ID); MutableProperty p = new MutableProperty(); p.ID = PropertyIDMap.PID_TITLE; p.Type = Variant.VT_LPSTR; p.Value = TITLE; ms.SetProperty(p); Exception t = null; try { MemoryStream out1 = new MemoryStream(); mps.Write(out1); out1.Close(); byte[] bytes = out1.ToArray(); PropertySet psr = new PropertySet(bytes); Assert.IsTrue(psr.IsSummaryInformation); Section sr = (Section)psr.Sections[0]; String title = (String)sr.GetProperty(PropertyIDMap.PID_TITLE); Assert.AreEqual(TITLE, title); } catch (WritingNotSupportedException e) { t = e; } catch (IOException e) { t = e; } catch (NoPropertySetStreamException e) { t = e; } if (t != null) { Assert.Fail(t.Message); } }
public void TestGetCustomerProperties() { long ID_1 = 2; long ID_2 = 3; String NAME_1 = "Schlüssel"; String VALUE_1 = "Wert 1"; Dictionary <object, object> dictionary = new Dictionary <object, object>(); DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation(); CustomProperties cps; MutableSection s; /* A document summary information Set stream by default does have custom properties. */ cps = dsi.CustomProperties; Assert.AreEqual(null, cps); /* Test an empty custom properties Set. */ s = new MutableSection(); s.SetFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID2); // s.SetCodepage(CodePageUtil.CP_UNICODE); dsi.AddSection(s); cps = dsi.CustomProperties; Assert.AreEqual(0, cps.Count); /* Add a custom property. */ MutableProperty p = new MutableProperty(); p.ID = ID_1; p.Type = Variant.VT_LPWSTR; p.Value = VALUE_1; s.SetProperty(p); dictionary[ID_1] = NAME_1; s.Dictionary = dictionary; cps = dsi.CustomProperties; Assert.AreEqual(1, cps.Count); Assert.IsTrue(cps.IsPure); /* Add another custom property. */ s.SetProperty((int)ID_2, Variant.VT_LPWSTR, VALUE_1); dictionary[ID_2] = NAME_1; s.Dictionary = dictionary; cps = dsi.CustomProperties; Assert.AreEqual(1, cps.Count); Assert.IsFalse(cps.IsPure); }
private AppViewModel(AppModel model) : base(model) { JamProperty = MutableProperty.Create <JamOverviewViewModel>(this, nameof(Jam), default !);
/// <summary> /// Adds a named date property. /// </summary> /// <param name="name">The property's name.</param> /// <param name="value">The property's value.</param> /// <returns>the property that was stored under the specified name before, or /// <c>null</c> /// if there was no such property before.</returns> public Object Put(String name,DateTime value) { MutableProperty p = new MutableProperty(); p.ID=-1; p.Type=Variant.VT_FILETIME; p.Value=value; CustomProperty cp = new CustomProperty(p, name); return Put(cp); }
/// <summary> /// Adds a named bool property. /// </summary> /// <param name="name">The property's name.</param> /// <param name="value">The property's value.</param> /// <returns>the property that was stored under the specified name before, or /// <c>null</c> /// if there was no such property before.</returns> public Object Put(String name, bool value) { MutableProperty p = new MutableProperty(); p.ID=-1; p.Type=Variant.VT_BOOL; p.Value=value; CustomProperty cp = new CustomProperty(p, name); return Put(cp); }
/// <summary> /// Constructs a <c>MutableSection</c> by doing a deep copy of an /// existing <c>Section</c>. All nested <c>Property</c> /// instances, will be their mutable counterparts in the new /// <c>MutableSection</c>. /// </summary> /// <param name="s">The section Set To copy</param> public MutableSection(Section s) { SetFormatID(s.FormatID); Property[] pa = s.Properties; MutableProperty[] mpa = new MutableProperty[pa.Length]; for (int i = 0; i < pa.Length; i++) mpa[i] = new MutableProperty(pa[i]); SetProperties(mpa); this.Dictionary=(s.Dictionary); }
/// <summary> /// Sets the value and the variant type of the property with the /// specified ID. If a property with this ID is not yet present in /// the section, it will be Added. An alReady present property with /// the specified ID will be overwritten. A default mapping will be /// used To choose the property's type. /// </summary> /// <param name="id">The property's ID.</param> /// <param name="variantType">The property's variant type.</param> /// <param name="value">The property's value.</param> public void SetProperty(int id, long variantType, Object value) { MutableProperty p = new MutableProperty(); p.ID=id; p.Type=variantType; p.Value=value; SetProperty(p); dirty = true; }
public AppViewModel() { DirectoryPathProperty = new MutableProperty <string>(this, nameof(DirectoryPath), string.Empty); GenerateJamFilesCommand = new SimpleCommand(GenerateJamFiles); }