Skip to content

Instantly share code, notes, and snippets.

public class Blah
{
[JsonIgnore]
public string Property { get; set; }
[JsonProperty(Name = "a")]
public int AnotherProperty { get; set; }
[JsonProperty(Name = "b")]
public SomeSuperDuperClass LastProperty { get; set; }
public class Directory
{
// ... fields omitted for brevity
public DirectoryType Type { get; private set; }
}
public class Calendar : Story
{
private Region _region;
private readonly ISet<Event> _events;
public Calendar(Guid id, Region region)
{
Id = id;
_region = region;
public class Calendar : Story
{
private string _region;
private readonly ISet<Event> _events;
public Calendar(Guid id, string region)
{
Id = id;
_region = region;
@cbcwebdev
cbcwebdev / Story.cs
Created May 20, 2012 18:40
TCOT base comain class
public abstract class Story : AggregateBase
{
private readonly ISet<Vote> _votes = new HashSet<Vote>();
private readonly ISet<Commentary> _comments = new HashSet<Commentary>();
private readonly ISet<Relevancy> _relevancies = new HashSet<Relevancy>();
protected Story()
{ }
public virtual Relevancy Relate(Story story, User contributor, RelevancyScore score)
@cbcwebdev
cbcwebdev / example.cs
Created May 14, 2012 20:33
Task Parallel Library
public partial class AwesomeSauceForm : Form
{
private Task _theTaskAtHand;
public AwesomeSauceForm()
{
InitializeComponent();
Task.Factory.StartNew(() =>
{
@cbcwebdev
cbcwebdev / directory.sql
Created May 3, 2012 22:05
Modern Directory Table Structure
CREATE TABLE [dbo].[Directories]
(
[AggregateId] UNIQUEIDENTIFIER NOT NULL,
[Name] NVARCHAR(64) NOT NULL,
[Route] NVARCHAR(128) NOT NULL UNIQUE,
[Route_Hash] AS CAST(HASHBYTES('SHA1', [Route]) AS VARBINARY(20)) PERSISTED UNIQUE,
[Depth] TINYINT NOT NULL,
[ParentId] UNIQUEIDENTIFIER NULL,
CONSTRAINT [PK_Directories] PRIMARY KEY NONCLUSTERED (
[AggregateId] ASC
@cbcwebdev
cbcwebdev / whoknows.cs
Created April 30, 2012 22:20
Use cases
/// <summary>
/// Keep in mind - factories are doing most object construction.
/// Trying to keep the idea simple to cut to the point...
/// </summary>
// when creating a client, we need the primary user (eg. account holder)
// the primary user may be created at the same point in time as the client, or be an existing user of any service
var client = new Client(Guid.NewCombGuid(), "Client Name", user);
// when creating a review on some entity in service ABC, assuming "entity" is present in context from some repository
@cbcwebdev
cbcwebdev / notes.txt
Created April 30, 2012 21:59
Business Scenarios
As an anonymous user, I can register in the network.
As a registered user, I can login to any service
As a registered user, I have global permissions, as well as permissions per service
As a registered user, I can become a client
As a client, I can register employees - who in turn, I assign global permissions, as well as permissions per service
...
service-abc.com ]
CREATE TABLE [dbo].[Accounts_Users](
[Id] [uniqueidentifier] NOT NULL,
[AccountId] [uniqueidentifier] NOT NULL,
[UserId] [uniqueidentifier] NOT NULL,
CONSTRAINT [PK_Accounts_Users] PRIMARY KEY CLUSTERED ([Id] ASC)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]