Skip to content

Instantly share code, notes, and snippets.

View amarwadi's full-sized avatar

Anup Marwadi amarwadi

View GitHub Profile
@amarwadi
amarwadi / KeyVaultEncryptionSerializer.cs
Last active March 11, 2019 05:16
Key Vault Encryption Serializer
public class KeyVaultEncryptionSerializer : IBsonSerializer
{
private readonly string _elementName;
public KeyVaultEncryptionSerializer(string elementName)
{
_elementName = elementName;
}
@amarwadi
amarwadi / InstallmentBsonMap.cs
Created January 27, 2018 18:55
Installment Class Mappings using Bson Mappers
public class InstallmentMap
{
public void Map()
{
BsonClassMap.RegisterClassMap<Installment>(map =>
{
map.AutoMap();
map.SetIgnoreExtraElements(true);
map.MapIdMember(x => x.Id);
map.MapMember(x => x.Title).SetIsRequired(true);
@amarwadi
amarwadi / Installment.cs
Created January 27, 2018 18:38
Installment Model with MongoDB Serialization attributes
[BsonIgnoreExtraElements]
public class Installment : AggregateRoot
{
[BsonId, BsonRepresentation(BsonType.ObjectId)]
public string Id { get; protected set; }
[BsonRequired]
public string Title { get; protected set; }
public string Description { get; protected set; }
@amarwadi
amarwadi / InstallmentsRevised.cs
Last active January 22, 2018 07:27
A revised Installment model
public class Installment : AggregateRoot
{
public string Id { get; private set; }
public string Title { get; protected set; }
public string Description { get; protected set; }
public uint InstallmentFrequencyInDays { get; protected set; }
public decimal DownPayment { get; protected set; }
public uint TotalInstallments { get; protected set; }
public Installment(string title, string description, uint installmentFrequencyDays, decimal downPayment, uint totalInstallments)
@amarwadi
amarwadi / Installment.cs
Created January 22, 2018 07:15
Installment Model - Initial
public class Installment
{
public string Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public uint InstallmentFrequencyInDays { get; set; }
public decimal DownPayment { get; set; }
public uint TotalInstallments { get; set; }
}
@amarwadi
amarwadi / DomainModel.cs
Created November 28, 2017 04:57
Conversion between Data and Domain Models
public class GoodDomainModel
{
public string Id {get; protected set; }
public Name Name {get; protected set; }
private GoodDomainModel(string id, Name name)
{
Id = id;
Name = name;
}
@amarwadi
amarwadi / C#
Last active January 3, 2016 06:54
using (var system = ActorSystem.Create("example123", config))
{
MongoDbPersistence.Instance.Apply(system);
var pActor = system.ActorOf(Props.Create<SectionActor>(), "section-actor");
pActor.Tell(new CheckSeatMessage("1", "1", new List<string> {"A", "B"}));
Console.ReadLine();
}