public override void Intercept(IInvocation invocation) { var info = new InvocationInfo(invocation); if (info.CallType == CallType.Set) { throw new Exception("Call to setter not allowed on an immutable type. Call Mutate() to get mutable object."); } if (info.Name == "IsNewModel") { invocation.ReturnValue = false; return; } if (info.Name == "Mutate") { invocation.ReturnValue = InstanceFactory.NewMutableRow(this.RowData, Transaction); return; } if (info.MethodType == MethodType.Property) { var name = info.Name; var property = Properties.Single(x => x.CsName == name); if (property.Type == PropertyType.Value) { invocation.ReturnValue = RowData.GetValue(property.Column.DbName); } else { invocation.ReturnValue = GetRelation(info); } return; } throw new NotImplementedException($"No handler for '{info.Name}' implemented"); }
public PrimaryKeys(RowData row) { Data = ReadRow(row).ToArray(); }
protected RowInterceptor(RowData rowData, Transaction transaction) { RowData = rowData; Transaction = transaction; }
public ImmutableRowInterceptor(RowData rowData, Transaction transaction) : base(rowData, transaction) { }
public MutableRowInterceptor(RowData rowData, Transaction transaction) : base(rowData, transaction) { this.MutableRowData = new MutableRowData(rowData); }
public MutableRowData(RowData immutableRowData) { this.ImmutableRowData = immutableRowData; }