コード例 #1
0
ファイル: RenameNode.cs プロジェクト: laszlo-kiss/Dataphor
        // Change
        protected override bool InternalChange(Program program, IRow oldRow, IRow newRow, BitArray valueFlags, string columnName)
        {
            if (PropagateChange)
            {
                TableNode sourceNode = SourceNode;

                IRow localOldRow;
                if (!(oldRow.DataType.Columns.Equivalent(DataType.Columns)))
                {
                    localOldRow = new Row(program.ValueManager, DataType.RowType);
                    oldRow.CopyTo(localOldRow);
                }
                else
                {
                    localOldRow = oldRow;
                }
                try
                {
                    IRow localNewRow;
                    if (!(newRow.DataType.Columns.Equivalent(DataType.Columns)))
                    {
                        localNewRow = new Row(program.ValueManager, DataType.RowType);
                        newRow.CopyTo(localNewRow);
                    }
                    else
                    {
                        localNewRow = newRow;
                    }
                    try
                    {
                        Row oldSourceRow = new Row(program.ValueManager, sourceNode.DataType.RowType, (NativeRow)localOldRow.AsNative);
                        try
                        {
                            oldSourceRow.ValuesOwned = false;

                            Row newSourceRow = new Row(program.ValueManager, sourceNode.DataType.RowType, (NativeRow)localNewRow.AsNative);
                            try
                            {
                                newSourceRow.ValuesOwned = false;

                                bool changed = sourceNode.Change(program, oldSourceRow, newSourceRow, valueFlags, columnName == String.Empty ? String.Empty : newSourceRow.DataType.Columns[localNewRow.DataType.Columns.IndexOfName(columnName)].Name);

                                if (changed && (newRow != localNewRow))
                                {
                                    localNewRow.CopyTo(newRow);
                                }

                                return(changed);
                            }
                            finally
                            {
                                newSourceRow.Dispose();
                            }
                        }
                        finally
                        {
                            oldSourceRow.Dispose();
                        }
                    }
                    finally
                    {
                        if (!ReferenceEquals(newRow, localNewRow))
                        {
                            localNewRow.Dispose();
                        }
                    }
                }
                finally
                {
                    if (!ReferenceEquals(oldRow, localOldRow))
                    {
                        localOldRow.Dispose();
                    }
                }
            }
            return(false);
        }