/// <summary> /// Add snapshot to buffer if snapshot with same timestamp exists in buffer. /// </summary> public void addSnapshot(Snapshot snapshot) { if (!Snapshots.ContainsKey(snapshot.Time)) { Snapshots.Add(snapshot.Time, snapshot); } }
public BlLink(MainUnitViewModel main) { LinkOptions = new ObservableCollection <LinkOption>(); _main = main; Location.X = XLocation; Cards(main.DataModel.ExpansionCards); for (var x = 0; x < 15; x++) { Snapshots.Add(new SnapShot(this) { Offset = { X = 0, Y = SnapshotHeight + RowHeight * x + _innerSpace(x) }, SnapType = SnapType.Gray, RowId = x }); Snapshots.Add(new SnapShot(this) { Offset = { X = Size.X, Y = SnapshotHeight + RowHeight * x + _innerSpace(x) }, SnapType = SnapType.Red, RowId = x }); } Snapshots.Add(new SnapShot(this) { Offset = { X = SnapshotWidth, Y = Size.Y }, RowId = 30 }); }
public void Snapshot(double fiat, double security, double securityPrice, double benchmarkPrice = 0) { if (benchmarkPrice == 0) { benchmarkPrice = securityPrice; } double portfolioValue = fiat + security * securityPrice; bool hasOne = Snapshots.Count > 0; var newSnapshot = new PortfolioSnapshot() { Time = DateTime.Now, Fiat = fiat, Security = security, SecurityPrice = securityPrice, PortfolioValue = portfolioValue, PL = Snapshots.Count > 0 ? portfolioValue / Snapshots.Last().PortfolioValue - 1 : 0.0, CumulativePL = hasOne ? portfolioValue / Snapshots.First().PortfolioValue - 1 : 0.0, BenchmarkPrice = benchmarkPrice, BenchmarkPL = hasOne ? benchmarkPrice / Snapshots.Last().BenchmarkPrice - 1 : 0.0, BenchmarkCumulativePL = hasOne ? benchmarkPrice / Snapshots.First().BenchmarkPrice - 1 : 0.0 }; Snapshots.Add(newSnapshot); SnapshotEvent?.Invoke(this, newSnapshot); CachedSharpeRatio = null; }
/// <inheritdoc /> public void AddSnapshot(ITableEntriesSnapshot newSnapshot, bool removeAllSnapshots = false) { if (removeAllSnapshots) { RemoveAllSnapshots(); } Snapshots.Add(newSnapshot); }
/// <summary> /// Add a snapshot to the list. /// </summary> /// <param name="snapshot">Snapshot to add.</param> public void Add(VMWareSnapshot snapshot) { if (snapshot.Parent != null && snapshot.Parent != _parent) { throw new InvalidOperationException("Snapshot already belongs to another collection."); } Snapshots.Add(snapshot); }
protected internal virtual void PrepareIndexAndSnapshots(SnapshotDeletionPolicy sdp, IndexWriter writer, int numSnapshots) { for (int i = 0; i < numSnapshots; i++) { // create dummy document to trigger commit. writer.AddDocument(new Document()); writer.Commit(); Snapshots.Add(sdp.Snapshot()); } }
/// <summary> /// Take a snapshot of the current state of the blueprint and add it to the snapshots collection /// </summary> public void TakeSnapshot() { if (Snapshots != null) { var snap = new SquareCellMap <CellGenerationType>(_Blueprint.SizeX, _Blueprint.SizeY); for (int i = 0; i < Blueprint.CellCount; i++) { snap[i] = Blueprint[i].GenerationType; } Snapshots.Add(snap); } }
public async Task with_snapshot_but_without_stream_should_throw_stale_aggregate_exception() { var ticketState = new TicketState(); var snapshot = new SnapshotInfo("Ticket_1", 2, ticketState, 1); await Snapshots.Add("Ticket_1", snapshot); var ex = await Assert.ThrowsAsync <StaleSnapshotException>(() => Repository.GetById <Ticket>("Ticket_1") ); Assert.Equal("Ticket_1", ex.AggregateId); Assert.Equal(2, ex.AggregateVersion); }
public virtual void TestExistingSnapshots() { int numSnapshots = 3; MockDirectoryWrapper dir = NewMockDirectory(); IndexWriter writer = new IndexWriter(dir, GetConfig(Random(), GetDeletionPolicy(dir))); PersistentSnapshotDeletionPolicy psdp = (PersistentSnapshotDeletionPolicy)writer.Config.IndexDeletionPolicy; Assert.IsNull(psdp.LastSaveFile); PrepareIndexAndSnapshots(psdp, writer, numSnapshots); Assert.IsNotNull(psdp.LastSaveFile); writer.Dispose(); // Make sure only 1 save file exists: int count = 0; foreach (string file in dir.ListAll()) { if (file.StartsWith(PersistentSnapshotDeletionPolicy.SNAPSHOTS_PREFIX, StringComparison.Ordinal)) { count++; } } Assert.AreEqual(1, count); // Make sure we fsync: dir.Crash(); dir.ClearCrash(); // Re-initialize and verify snapshots were persisted psdp = new PersistentSnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy(), dir, OpenMode.APPEND); writer = new IndexWriter(dir, GetConfig(Random(), psdp)); psdp = (PersistentSnapshotDeletionPolicy)writer.Config.IndexDeletionPolicy; Assert.AreEqual(numSnapshots, psdp.GetSnapshots().Count); Assert.AreEqual(numSnapshots, psdp.SnapshotCount); AssertSnapshotExists(dir, psdp, numSnapshots, false); writer.AddDocument(new Document()); writer.Commit(); Snapshots.Add(psdp.Snapshot()); Assert.AreEqual(numSnapshots + 1, psdp.GetSnapshots().Count); Assert.AreEqual(numSnapshots + 1, psdp.SnapshotCount); AssertSnapshotExists(dir, psdp, numSnapshots + 1, false); writer.Dispose(); dir.Dispose(); }
GetSubVolumeInfo(string SourcePath, string fullpath, CancellationToken ct) { var res = await Toolkit.Exec("btrfs", new[] { "sub", "show", fullpath }, ct, development); var uuid = ""; var parentUUID = ""; var generation = 0L; var genAtCreation = 0L; List <string> Snapshots = null; foreach (var y in res.output.Lines()) { if (y.Trim().StartsWith("UUID:")) { uuid = y.Trim().StripBegin("UUID:").Trim(); } else if (y.Trim().StartsWith("Parent UUID:")) { parentUUID = y.Trim().StripBegin("Parent UUID:").Trim(); } else if (y.Trim().StartsWith("Generation:")) { generation = long.Parse(y.Trim().StripBegin("Generation:").Trim()); } else if (y.Trim().StartsWith("Gen at creation:")) { genAtCreation = long.Parse(y.Trim().StripBegin("Gen at creation:").Trim()); } else if (y.Trim().StartsWith("Snapshot(s):")) { Snapshots = new List <string>(); } else if (Snapshots != null) { Snapshots.Add(Path.Combine(SourcePath, y.Trim())); } } if (Snapshots == null) { Snapshots = new List <string>(); } return(uuid, parentUUID, generation, genAtCreation, Snapshots); }
public BlEmergency(MainUnitViewModel main) { _main = main; for (var x = 0; x < 5; x++) { Snapshots.Add(new SnapShot(this) { Offset = { X = 0, Y = SnapshotHeight + RowHeight * x }, SnapType = SnapType.Gray, RowId = x }); } Snapshots.Add(new SnapShot(this) { Offset = { X = SnapshotWidth, Y = 0 }, RowId = 30 }); Location.X = XLocation; SetYLocation(); UpdatePanelCount(); }
public override void Deserialize(XmlNode rootNode) { base.Deserialize(rootNode); var node = rootNode.SelectSingleNode(@"ProgramSchedule"); if (node != null) { InitProgramSchedule(); ProgramSchedule.Deserialize(node); } node = rootNode.SelectSingleNode(@"WeeklySection"); if (node != null && SelectedSpotType == SpotType.Week) { InitProgramSchedule(); ProgramSchedule.DeserializeSection(node); } node = rootNode.SelectSingleNode(@"MonthlySection"); if (node != null && SelectedSpotType == SpotType.Month) { InitProgramSchedule(); ProgramSchedule.DeserializeSection(node); } node = rootNode.SelectSingleNode(@"DigitalProducts"); if (node != null) { foreach (XmlNode productNode in node.ChildNodes) { var product = new DigitalProduct(); product.Deserialize(productNode); DigitalProducts.Add(product); } } node = rootNode.SelectSingleNode(@"DigitalProductSummary"); if (node != null) { DigitalProductSummary.Deserialize(node); } node = rootNode.SelectSingleNode(@"Snapshots"); if (node != null) { foreach (XmlNode snapshotNode in node.ChildNodes) { var snapshot = new Snapshot.Snapshot(this); snapshot.Deserialize(snapshotNode); Snapshots.Add(snapshot); } } node = rootNode.SelectSingleNode(@"SnapshotSummary"); if (node != null) { SnapshotSummary.Deserialize(node); } node = rootNode.SelectSingleNode(@"Options"); if (node != null) { foreach (XmlNode optionSetNode in node.ChildNodes) { var optionSet = new OptionSet(this); optionSet.Deserialize(optionSetNode); Options.Add(optionSet); } } node = rootNode.SelectSingleNode(@"OptionsSummary"); if (node != null) { OptionsSummary.Deserialize(node); } }
public virtual void AddSnapshot(PostSnapshotDomain snapshot) { snapshot.SetPost(this); Snapshots.Add(snapshot); }