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