This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TimedProcessor | |
{ | |
/// <summary> | |
/// Times the TimedProcessor has fired its Elapsed function | |
/// </summary> | |
public int TimesElapsed { get; set; } | |
/// <summary> | |
/// Indicates whether or not the TimedProcessor is running | |
/// </summary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<bool> IsLocationInUse(string setId, string country, string state, CancellationToken cancellationToken = default) | |
{ | |
bool isLocationInUse = await MySetCollection.Aggregate() | |
.Match(x => x.SetId == setId) | |
.Project(Builders<MyDataSet>.Projection | |
.Include("Attributes.State") | |
.Include("Attributes.Country") | |
.Exclude("_id")) | |
.Unwind("Attributes") | |
.Match(new BsonDocument { { "Attributes.State", state }, { "Attributes.Country", country } }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyDataSet | |
{ | |
public string SetId { get; set; } | |
public string Name { get; set; } | |
public List<Attributes> Attributes { get; set; } | |
} | |
public class Attributes | |
{ | |
public string State { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MongoDelete() | |
{ | |
private MongoClient Client = new MongoClient("mongodb://connectionString"); | |
private IMongoDatabase Db = Client.GetDatabase("MyDatabaseName"); | |
private IMongoCollection<MyEntity> Collection = Db.GetCollection<MyEntity>("MyCollection"); | |
public async Task Delete(string key, int id) | |
{ | |
await Collection.UpdateOneAsync(x => x.Key == key && x.Items.Any(i => i.Id == id), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MongoUpdate() | |
{ | |
private MongoClient Client = new MongoClient("mongodb://connectionString"); | |
private IMongoDatabase Db = Client.GetDatabase("MyDatabaseName"); | |
private IMongoCollection<MyEntity> Collection = Db.GetCollection<MyEntity>("MyCollection"); | |
public async Task Update(string key, int id, MyEntityItem newEntityItem) | |
{ | |
await Collection.UpdateOneAsync(x => x.Key == key && x.Items.Any(i => i.Id == id), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MongoRead() | |
{ | |
private MongoClient Client = new MongoClient("mongodb://connectionString"); | |
private IMongoDatabase Db = Client.GetDatabase("MyDatabaseName"); | |
private IMongoCollection<MyEntity> Collection = Db.GetCollection<MyEntity>("MyCollection"); | |
public async Task<IEnumerable<MyEntityItem>> Read(string key) | |
{ | |
var cursor = await Collection.FindAsync(x => x.Key == key).ConfigureAwait(false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MongoCreate() | |
{ | |
private MongoClient Client = new MongoClient("mongodb://connectionString"); | |
private IMongoDatabase Db = Client.GetDatabase("MyDatabaseName"); | |
private IMongoCollection<MyEntity> Collection = Db.GetCollection<MyEntity>("MyCollection"); | |
public async Task Add(string key, params MyEntityItem[] items) | |
{ | |
await Collection.UpdateOneAsync(x => x.Key == key, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[BsonIgnoreExtraElements] | |
public class MyEntity | |
{ | |
public string Key { get; set; } | |
public List<MyEntityItem> Items { get; set; } = new List<MyEntityItem>(); | |
} | |
public class MyEntityItem | |
{ | |
public string Name { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Typescript | |
svg.on("click", () => { | |
const coords = d3.mouse(svg.node()); | |
console.log(coords); | |
}); | |
// Typescript | |
svg.on("click", () => { | |
const coords = d3.mouse(d3.event.currentTarget); | |
console.log(coords); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Javascript | |
svg.on("click", function() { | |
var coords = d3.mouse(this); | |
console.log(coords); | |
}); |