コード例 #1
0
ファイル: RenameNode.cs プロジェクト: laszlo-kiss/Dataphor
        // Validate
        protected override bool InternalValidate(Program program, IRow oldRow, IRow newRow, BitArray valueFlags, string columnName, bool isDescending, bool isProposable)
        {
            if (isDescending && PropagateValidate)
            {
                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.Validate(program, oldSourceRow, newSourceRow, valueFlags, columnName == String.Empty ? String.Empty : newSourceRow.DataType.Columns[localNewRow.DataType.Columns.IndexOfName(columnName)].Name);

                                if (changed && !ReferenceEquals(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);
        }