Skip to content

Instantly share code, notes, and snippets.

View Skamiplan's full-sized avatar

Maikel Skamiplan

  • The Netherlands
View GitHub Profile
@Skamiplan
Skamiplan / Refactor.cs
Created February 23, 2020 17:31
Refactor Code with Roslyn
using Microsoft.CodeAnalysis;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
internal class MongoTracking
{
private readonly Action<CommandStartedEvent> onCommandStartEvent;
private readonly Action<CommandSucceededEvent> onCommandSucceededEvent;
private readonly Action<CommandFailedEvent> onCommandFailedEvent;
private IEnumerable<string> NotTrackedCommands { get; } = new[]
{"isMaster", "buildInfo", "getLastError", "saslStart", "saslContinue"};
@Skamiplan
Skamiplan / GenericLookup.cs
Last active July 9, 2020 19:33
A basic example on how to generically do (Entity Framework like) relations in Mongo, although at this point only 1 object deep.
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics;
using System.Linq;
namespace Looking