Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 53 lines (43 sloc) 1.335 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
using System;
using System.Linq;
using System.Collections.Generic;

namespace FluentCassandra
{
public class FluentMutationTracker : IFluentMutationTracker
{
private IList<FluentMutation> _mutation;

protected internal FluentMutationTracker(IFluentRecord parentRecord)
{
ParentRecord = parentRecord;
_mutation = new List<FluentMutation>();
}

public IFluentRecord ParentRecord { get; private set; }

public virtual void ColumnMutated(MutationType type, IFluentBaseColumn column)
{
if (ParentRecord is FluentSuperColumn)
{
var superColumn = (FluentSuperColumn)ParentRecord;
var superColumnFamilyMutationTracker = superColumn.Family.MutationTracker;

// check to see if there is a mutation for this column already, so we don't create duplicate mutations
if (!superColumnFamilyMutationTracker.GetMutations().Any(x => x.Column.ColumnName == superColumn.ColumnName))
superColumnFamilyMutationTracker.ColumnMutated(MutationType.Changed, superColumn);
}

_mutation.Add(new FluentMutation {
Type = type,
Column = column
});
}

protected internal void Remove(FluentMutation mutation)
{
_mutation.Remove(mutation);
}

public virtual void Clear()
{
_mutation.Clear();
}

public IEnumerable<FluentMutation> GetMutations()
{
return _mutation;
}
}
}
Something went wrong with that request. Please try again.