Example #1
0
        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");
        }
Example #2
0
 public PrimaryKeys(RowData row)
 {
     Data = ReadRow(row).ToArray();
 }
Example #3
0
 protected RowInterceptor(RowData rowData, Transaction transaction)
 {
     RowData     = rowData;
     Transaction = transaction;
 }
Example #4
0
 public ImmutableRowInterceptor(RowData rowData, Transaction transaction) : base(rowData, transaction)
 {
 }
Example #5
0
 public MutableRowInterceptor(RowData rowData, Transaction transaction) : base(rowData, transaction)
 {
     this.MutableRowData = new MutableRowData(rowData);
 }
Example #6
0
 public MutableRowData(RowData immutableRowData)
 {
     this.ImmutableRowData = immutableRowData;
 }