Example #1
0
        /// <inheritdoc />
        protected override void OnFrameApply(ImageFrame <TPixel> source)
        {
            var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds());

            // We need a clean copy for each pass to start from
            using ImageFrame <TPixel> cleanCopy = source.Clone();

            using (var processor = new ConvolutionProcessor <TPixel>(this.Configuration, in this.kernels[0], true, this.Source, interest))
            {
                processor.Apply(source);
            }

            if (this.kernels.Length == 1)
            {
                return;
            }

            // Additional runs
            for (int i = 1; i < this.kernels.Length; i++)
            {
                using ImageFrame <TPixel> pass = cleanCopy.Clone();

                using (var processor = new ConvolutionProcessor <TPixel>(this.Configuration, in this.kernels[i], true, this.Source, interest))
                {
                    processor.Apply(pass);
                }

                var operation = new RowOperation(source.PixelBuffer, pass.PixelBuffer, interest);
                ParallelRowIterator.IterateRows(
                    this.Configuration,
                    interest,
                    in operation);
            }
        }
Example #2
0
 private void OperateOnSubmitRange(RowOperation operation, IEnumerable <TEntity> entities)
 {
     foreach (var entity in entities)
     {
         OperateOnSubmit(operation, entity);
     }
 }
Example #3
0
 internal void SetPrincipalOperation(RowOperation operation)
 {
     if (this.Operation < operation)
     {
         this.Operation = operation;
     }
 }
        /// <inheritdoc/>
        protected override void OnFrameApply(ImageFrame <TPixel> source)
        {
            TPixel glowColor    = this.definition.GlowColor.ToPixel <TPixel>();
            float  blendPercent = this.definition.GraphicsOptions.BlendPercentage;

            var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds());

            Vector2 center      = Rectangle.Center(interest);
            float   finalRadius = this.definition.Radius.Calculate(interest.Size);
            float   maxDistance = finalRadius > 0
                ? MathF.Min(finalRadius, interest.Width * .5F)
                : interest.Width * .5F;

            Configuration   configuration = this.Configuration;
            MemoryAllocator allocator     = configuration.MemoryAllocator;

            using IMemoryOwner <TPixel> rowColors = allocator.Allocate <TPixel>(interest.Width);
            rowColors.GetSpan().Fill(glowColor);

            var operation = new RowOperation(configuration, interest, rowColors, this.blender, center, maxDistance, blendPercent, source);

            ParallelRowIterator.IterateRows <RowOperation, float>(
                configuration,
                interest,
                in operation);
        }
Example #5
0
        /// <summary>
        /// Swaps the image at the Y-axis, which goes vertically through the middle at half of the width of the image.
        /// </summary>
        /// <param name="source">The source image to apply the process to.</param>
        /// <param name="configuration">The configuration.</param>
        private void FlipY(ImageFrame <TPixel> source, Configuration configuration)
        {
            var operation = new RowOperation(source);

            ParallelRowIterator.IterateRows(
                configuration,
                source.Bounds(),
                in operation);
        }
Example #6
0
        /// <inheritdoc/>
        protected override void OnFrameApply(ImageFrame <TPixel> source)
        {
            var interest  = Rectangle.Intersect(this.SourceRectangle, source.Bounds());
            var operation = new RowOperation(interest.X, source, this.definition.Matrix, this.Configuration);

            ParallelRowIterator.IterateRows <RowOperation, Vector4>(
                this.Configuration,
                interest,
                in operation);
        }
Example #7
0
 /// <summary>
 /// Creates a shallow copy of a row from another row.
 /// </summary>
 /// <param name="source">The row the data is copied from.</param>
 protected Row(Row source)
 {
     this.table             = source.table;
     this.tableDefinition   = source.tableDefinition;
     this.rowNumber         = source.rowNumber;
     this.operation         = source.operation;
     this.sectionId         = source.sectionId;
     this.sourceLineNumbers = source.sourceLineNumbers;
     this.fields            = source.fields;
     this.symbol            = source.symbol;
 }
Example #8
0
        /// <summary>
        /// Executa ação definida para o registro no objeto de destino
        /// </summary>
        /// <param name="rowOp">Operação que deverás er executada</param>
        /// <param name="transformedRow">Linha que foi transformada</param>
        public void ProcessTransformedRow(RowOperation rowOp, DictionaryRow transformedRow)
        {
            if (this.RowBeforeProcess != null)
            {
                this.RowBeforeProcess(transformedRow, rowOp);
            }

            try
            {
                switch (rowOp)
                {
                case RowOperation.Process:
                    _dest.Process(transformedRow);
                    break;

                case RowOperation.Insert:
                    _dest.Insert(transformedRow);
                    break;

                case RowOperation.Update:
                    _dest.Update(transformedRow);
                    break;

                case RowOperation.Delete:
                    _dest.Delete(transformedRow);
                    break;
                }

                if (this.RowSuccess != null && rowOp != RowOperation.Ignore)
                {
                    this.RowSuccess(transformedRow, rowOp);
                }
            }
            catch (Exception exRow)
            {
                if (this.RowError != null)
                {
                    this.RowError(transformedRow, rowOp, exRow);
                }
                else
                {
                    throw exRow;
                }
            }

            if (this.RowAfterProcess != null)
            {
                this.RowAfterProcess(transformedRow, rowOp);
            }
        }
Example #9
0
        private void OperateOnSubmit(RowOperation operation, TEntity entity)
        {
            SqlMaker gen = this.Generator;

            var dict = broker.ToDictionary(entity);

            gen.AddRange(dict);

            string sql = null;

            switch (operation)
            {
            case RowOperation.Insert:
                sql = gen.Insert();
                break;

            case RowOperation.Update:
                sql = gen.Update();
                break;

            case RowOperation.InsertOrUpdate:
                sql = gen.InsertOrUpdate();
                break;

            case RowOperation.Delete:
                sql = gen.Delete();
                break;
            }

            if (sql == null)
            {
                return;
            }

            Context.CodeBlock.AppendLine <TEntity>(sql);

            var evt = new RowEvent
            {
                TypeName  = typeof(TEntity).Name,
                Operation = operation,
                Row       = gen.ToDictionary(),
            };

            Context.RowEvents.Add(evt);
            gen.Clear();
        }
Example #10
0
        /// <inheritdoc/>
        protected override void OnFrameApply(ImageFrame <TPixel> source)
        {
            byte   threshold = (byte)MathF.Round(this.definition.Threshold * 255F);
            TPixel upper     = this.definition.UpperColor.ToPixel <TPixel>();
            TPixel lower     = this.definition.LowerColor.ToPixel <TPixel>();

            Rectangle     sourceRectangle = this.SourceRectangle;
            Configuration configuration   = this.Configuration;

            var  interest    = Rectangle.Intersect(sourceRectangle, source.Bounds());
            bool isAlphaOnly = typeof(TPixel) == typeof(A8);

            var operation = new RowOperation(interest, source, upper, lower, threshold, isAlphaOnly);

            ParallelRowIterator.IterateRows(
                configuration,
                interest,
                in operation);
        }
Example #11
0
        /// <summary>
        /// Indica que está no contexto de transformação do objeto
        /// </summary>
        /// <param name="context">Contexto de transformação</param>
        /// <param name="action">Ação que será executada para a transformação</param>
        protected override void InTransformContext(Unimake.ETL.ITransform context, System.Action action)
        {
            ObjectResult = new T();

            foreach (var inputRow in context.Source.Rows)
            {
                RowValidation rowValidation = new RowValidation();
                context.DoRowValidation(inputRow, rowValidation);
                if (rowValidation.HasErrors)
                {
                    context.RaiseRowInvalid(inputRow, rowValidation);
                }
                else
                {
                    RowOperation rowOp = context.GetRowOperation(inputRow);
                    if (rowOp != RowOperation.Ignore)
                    {
                        DictionaryRow transformedRow = new DictionaryRow();
                        foreach (var mapping in context.TransformMap)
                        {
                            object rowValue = inputRow[mapping.Key];
                            Func <object, object> transformFunc;
                            if (context.TransformFuncs.TryGetValue(mapping.Key, out transformFunc))
                            {
                                rowValue = transformFunc(rowValue);
                            }
                            transformedRow[mapping.Value] = rowValue;

                            //aqui temos que preencher o objeto com suas propriedades
                            SetValue(mapping, rowValue);
                        }

                        context.ProcessTransformedRow(rowOp, transformedRow);
                    }
                }
            }
        }
        /// <inheritdoc/>
        protected override void OnFrameApply(ImageFrame <TPixelBg> source)
        {
            Rectangle     sourceRectangle = this.SourceRectangle;
            Configuration configuration   = this.Configuration;

            Image <TPixelFg>        targetImage = this.Image;
            PixelBlender <TPixelBg> blender     = this.Blender;
            int locationY = this.Location.Y;

            // Align start/end positions.
            Rectangle bounds = targetImage.Bounds();

            int minX    = Math.Max(this.Location.X, sourceRectangle.X);
            int maxX    = Math.Min(this.Location.X + bounds.Width, sourceRectangle.Right);
            int targetX = minX - this.Location.X;

            int minY = Math.Max(this.Location.Y, sourceRectangle.Y);
            int maxY = Math.Min(this.Location.Y + bounds.Height, sourceRectangle.Bottom);

            int width = maxX - minX;

            var workingRect = Rectangle.FromLTRB(minX, minY, maxX, maxY);

            // Not a valid operation because rectangle does not overlap with this image.
            if (workingRect.Width <= 0 || workingRect.Height <= 0)
            {
                throw new ImageProcessingException(
                          "Cannot draw image because the source image does not overlap the target image.");
            }

            var operation = new RowOperation(source, targetImage, blender, configuration, minX, width, locationY, targetX, this.Opacity);

            ParallelRowIterator.IterateRows(
                configuration,
                workingRect,
                in operation);
        }
Example #13
0
 private KuduOperation NewOperation(RowOperation rowOperation)
 {
     return(new KuduOperation(this, rowOperation));
 }
Example #14
0
        private Row CompareRows(Table targetTable, Row targetRow, Row updatedRow, out RowOperation operation, out bool keepRow)
        {
            Row comparedRow = null;
            keepRow = false;
            operation = RowOperation.None;

            if (null == targetRow ^ null == updatedRow)
            {
                if (null == targetRow)
                {
                    operation = updatedRow.Operation = RowOperation.Add;
                    comparedRow = updatedRow;
                }
                else if (null == updatedRow)
                {
                    operation = targetRow.Operation = RowOperation.Delete;
                    targetRow.SectionId = targetRow.SectionId + sectionDelimiter;
                    comparedRow = targetRow;
                    keepRow = true;
                }
            }
            else // possibly modified
            {
                updatedRow.Operation = RowOperation.None;
                if (!this.suppressKeepingSpecialRows && "_SummaryInformation" == targetTable.Name)
                {
                    // ignore rows that shouldn't be in a transform
                    if (Enum.IsDefined(typeof(SummaryInformation.Transform), (int)updatedRow[0]))
                    {
                        updatedRow.SectionId = targetRow.SectionId + sectionDelimiter + updatedRow.SectionId;
                        comparedRow = updatedRow;
                        keepRow = true;
                        operation = RowOperation.Modify;
                    }
                }
                else
                {
                    if (this.preserveUnchangedRows)
                    {
                        keepRow = true;
                    }

                    for (int i = 0; i < updatedRow.Fields.Length; i++)
                    {
                        ColumnDefinition columnDefinition = updatedRow.Fields[i].Column;

                        if (!columnDefinition.IsPrimaryKey)
                        {
                            bool modified = false;

                            if (i >= targetRow.Fields.Length)
                            {
                                columnDefinition.Added = true;
                                modified = true;
                            }
                            else if (ColumnType.Number == columnDefinition.Type && !columnDefinition.IsLocalizable)
                            {
                                if (null == targetRow[i] ^ null == updatedRow[i])
                                {
                                    modified = true;
                                }
                                else if (null != targetRow[i] && null != updatedRow[i])
                                {
                                    modified = ((int)targetRow[i] != (int)updatedRow[i]);
                                }
                            }
                            else if (ColumnType.Preserved == columnDefinition.Type)
                            {
                                updatedRow.Fields[i].PreviousData = (string)targetRow.Fields[i].Data;

                                // keep rows containing preserved fields so the historical data is available to the binder
                                keepRow = !this.suppressKeepingSpecialRows;
                            }
                            else if (ColumnType.Object == columnDefinition.Type)
                            {
                                ObjectField targetObjectField = (ObjectField)targetRow.Fields[i];
                                ObjectField updatedObjectField = (ObjectField)updatedRow.Fields[i];

                                updatedObjectField.PreviousCabinetFileId = targetObjectField.CabinetFileId;
                                updatedObjectField.PreviousBaseUri = targetObjectField.BaseUri;

                                // always keep a copy of the previous data even if they are identical
                                // This makes diff.wixmst clean and easier to control patch logic
                                updatedObjectField.PreviousData = (string)targetObjectField.Data;

                                // always remember the unresolved data for target build
                                updatedObjectField.UnresolvedPreviousData = (string)targetObjectField.UnresolvedData;

                                // keep rows containing object fields so the files can be compared in the binder
                                keepRow = !this.suppressKeepingSpecialRows;
                            }
                            else
                            {
                                modified = ((string)targetRow[i] != (string)updatedRow[i]);
                            }

                            if (modified)
                            {
                                if (null != updatedRow.Fields[i].PreviousData)
                                {
                                    updatedRow.Fields[i].PreviousData = targetRow.Fields[i].Data.ToString();
                                }

                                updatedRow.Fields[i].Modified = true;
                                operation = updatedRow.Operation = RowOperation.Modify;
                                keepRow = true;
                            }
                        }
                    }

                    if (keepRow)
                    {
                        comparedRow = updatedRow;
                        comparedRow.SectionId = targetRow.SectionId + sectionDelimiter + updatedRow.SectionId;
                    }
                }
            }

            return comparedRow;
        }
 internal PartialRowOperation(PartialRowOperation row, RowOperation operation)
     : base(row)
 {
     Operation = operation;
 }
Example #16
0
        /// <summary>
        /// Executa o processo de transformação do objeto e retorna o resultado transformado
        /// </summary>
        /// <returns></returns>
        public Transform Execute()
        {
            if (TransformMap.Count == 0)
            {
                throw new InvalidOperationException("No mappings defined.");
            }

            if (this.Start != null)
            {
                this.Start(this);
            }

            try
            {
                Source.InTransformContext(this, () =>
                {
                    _dest.InTransformContext(this, () =>
                    {
                        foreach (var inputRow in Source.Rows)
                        {
                            RowValidation rowValidation = new RowValidation();
                            DoRowValidation(inputRow, rowValidation);
                            if (rowValidation.HasErrors)
                            {
                                if (this.RowInvalid != null)
                                {
                                    this.RowInvalid(inputRow, rowValidation);
                                }
                            }
                            else
                            {
                                RowOperation rowOp = this.GetRowOperation(inputRow);
                                if (rowOp != RowOperation.Ignore)
                                {
                                    DictionaryRow transformedRow = new DictionaryRow();
                                    foreach (var mapping in TransformMap)
                                    {
                                        object rowValue = inputRow[mapping.Key];
                                        Func <object, object> transformFunc;
                                        if (TransformFuncs.TryGetValue(mapping.Key, out transformFunc))
                                        {
                                            rowValue = transformFunc(rowValue);
                                        }
                                        transformedRow[mapping.Value] = rowValue;
                                    }

                                    ProcessTransformedRow(rowOp, transformedRow);
                                }
                            }
                        }
                    });
                });
            }
            catch (Exception exTransform)
            {
                if (this.Error != null)
                {
                    this.Error(this, exTransform);
                }
                else
                {
                    throw exTransform;
                }
            }

            if (this.Complete != null)
            {
                this.Complete(this);
            }

            return(this);
        }
Example #17
0
File: Row.cs Project: bleissem/wix3
        /// <summary>
        /// Creates a Row from the XmlReader.
        /// </summary>
        /// <param name="reader">Reader to get data from.</param>
        /// <param name="table">Table for this row.</param>
        /// <returns>New row object.</returns>
        internal static Row Parse(XmlReader reader, Table table)
        {
            Debug.Assert("row" == reader.LocalName);

            bool empty = reader.IsEmptyElement;
            RowOperation operation = RowOperation.None;
            string sectionId = null;
            SourceLineNumberCollection sourceLineNumbers = null;

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "op":
                        switch (reader.Value)
                        {
                            case "add":
                                operation = RowOperation.Add;
                                break;
                            case "delete":
                                operation = RowOperation.Delete;
                                break;
                            case "modify":
                                operation = RowOperation.Modify;
                                break;
                            default:
                                throw new WixException(WixErrors.IllegalAttributeValue(SourceLineNumberCollection.FromUri(reader.BaseURI), "row", reader.Name, reader.Value, "Add", "Delete", "Modify"));
                        }
                        break;
                    case "sectionId":
                        sectionId = reader.Value;
                        break;
                    case "sourceLineNumber":
                        sourceLineNumbers = new SourceLineNumberCollection(reader.Value);
                        break;
                    default:
                        if (!reader.NamespaceURI.StartsWith("http://www.w3.org/", StringComparison.Ordinal))
                        {
                            throw new WixException(WixErrors.UnexpectedAttribute(SourceLineNumberCollection.FromUri(reader.BaseURI), "row", reader.Name));
                        }
                        break;
                }
            }

            Row row = table.CreateRow(sourceLineNumbers);
            row.Operation = operation;
            row.SectionId = sectionId;

            // loop through all the fields in a row
            if (!empty)
            {
                bool done = false;
                int field = 0;

                // loop through all the fields in a row
                while (!done && reader.Read())
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element:
                            switch (reader.LocalName)
                            {
                                case "field":
                                    if (row.Fields.Length <= field)
                                    {
                                        if (!reader.IsEmptyElement)
                                        {
                                            throw new WixException(WixErrors.UnexpectedColumnCount(SourceLineNumberCollection.FromUri(reader.BaseURI), table.Name));
                                        }
                                    }
                                    else
                                    {
                                        row.fields[field].Parse(reader);
                                    }
                                    ++field;
                                    break;
                                default:
                                    throw new WixException(WixErrors.UnexpectedElement(SourceLineNumberCollection.FromUri(reader.BaseURI), "row", reader.Name));
                            }
                            break;
                        case XmlNodeType.EndElement:
                            done = true;
                            break;
                    }
                }

                if (!done)
                {
                    throw new WixException(WixErrors.ExpectedEndElement(SourceLineNumberCollection.FromUri(reader.BaseURI), "row"));
                }
            }

            return row;
        }
Example #18
0
File: Row.cs Project: bleissem/wix3
 /// <summary>
 /// Creates a shallow copy of a row from another row.
 /// </summary>
 /// <param name="source">The row the data is copied from.</param>
 protected Row(Row source)
 {
     this.table = source.table;
     this.tableDefinition = source.tableDefinition;
     this.rowNumber = source.rowNumber;
     this.operation = source.operation;
     this.sectionId = source.sectionId;
     this.sourceLineNumbers = source.sourceLineNumbers;
     this.fields = source.fields;
     this.symbol = source.symbol;
 }
 public PartialRowOperation(KuduSchema schema, RowOperation operation)
     : base(schema)
 {
     Operation = operation;
 }
Example #20
0
        private Row CompareRows(Table targetTable, Row targetRow, Row updatedRow, out RowOperation operation, out bool keepRow)
        {
            Row comparedRow = null;

            keepRow   = false;
            operation = RowOperation.None;

            if (null == targetRow ^ null == updatedRow)
            {
                if (null == targetRow)
                {
                    operation   = updatedRow.Operation = RowOperation.Add;
                    comparedRow = updatedRow;
                }
                else if (null == updatedRow)
                {
                    operation           = targetRow.Operation = RowOperation.Delete;
                    targetRow.SectionId = targetRow.SectionId + sectionDelimiter;
                    comparedRow         = targetRow;
                    keepRow             = true;
                }
            }
            else // possibly modified
            {
                updatedRow.Operation = RowOperation.None;
                if (!this.suppressKeepingSpecialRows && "_SummaryInformation" == targetTable.Name)
                {
                    // ignore rows that shouldn't be in a transform
                    if (Enum.IsDefined(typeof(SummaryInformation.Transform), (int)updatedRow[0]))
                    {
                        updatedRow.SectionId = targetRow.SectionId + sectionDelimiter + updatedRow.SectionId;
                        comparedRow          = updatedRow;
                        keepRow   = true;
                        operation = RowOperation.Modify;
                    }
                }
                else
                {
                    if (this.preserveUnchangedRows)
                    {
                        keepRow = true;
                    }

                    for (int i = 0; i < updatedRow.Fields.Length; i++)
                    {
                        ColumnDefinition columnDefinition = updatedRow.Fields[i].Column;

                        if (!columnDefinition.IsPrimaryKey)
                        {
                            bool modified = false;

                            if (i >= targetRow.Fields.Length)
                            {
                                columnDefinition.Added = true;
                                modified = true;
                            }
                            else if (ColumnType.Number == columnDefinition.Type && !columnDefinition.IsLocalizable)
                            {
                                if (null == targetRow[i] ^ null == updatedRow[i])
                                {
                                    modified = true;
                                }
                                else if (null != targetRow[i] && null != updatedRow[i])
                                {
                                    modified = ((int)targetRow[i] != (int)updatedRow[i]);
                                }
                            }
                            else if (ColumnType.Preserved == columnDefinition.Type)
                            {
                                updatedRow.Fields[i].PreviousData = (string)targetRow.Fields[i].Data;

                                // keep rows containing preserved fields so the historical data is available to the binder
                                keepRow = !this.suppressKeepingSpecialRows;
                            }
                            else if (ColumnType.Object == columnDefinition.Type)
                            {
                                ObjectField targetObjectField  = (ObjectField)targetRow.Fields[i];
                                ObjectField updatedObjectField = (ObjectField)updatedRow.Fields[i];

                                updatedObjectField.PreviousCabinetFileId = targetObjectField.CabinetFileId;
                                updatedObjectField.PreviousBaseUri       = targetObjectField.BaseUri;

                                // always keep a copy of the previous data even if they are identical
                                // This makes diff.wixmst clean and easier to control patch logic
                                updatedObjectField.PreviousData = (string)targetObjectField.Data;

                                // always remember the unresolved data for target build
                                updatedObjectField.UnresolvedPreviousData = (string)targetObjectField.UnresolvedData;

                                // keep rows containing object fields so the files can be compared in the binder
                                keepRow = !this.suppressKeepingSpecialRows;
                            }
                            else
                            {
                                modified = ((string)targetRow[i] != (string)updatedRow[i]);
                            }

                            if (modified)
                            {
                                if (null != updatedRow.Fields[i].PreviousData)
                                {
                                    updatedRow.Fields[i].PreviousData = targetRow.Fields[i].Data.ToString();
                                }

                                updatedRow.Fields[i].Modified = true;
                                operation = updatedRow.Operation = RowOperation.Modify;
                                keepRow   = true;
                            }
                        }
                    }

                    if (keepRow)
                    {
                        comparedRow           = updatedRow;
                        comparedRow.SectionId = targetRow.SectionId + sectionDelimiter + updatedRow.SectionId;
                    }
                }
            }

            return(comparedRow);
        }
Example #21
0
        private RowCollection CompareTables(Output targetOutput, Table targetTable, Table updatedTable, out TableOperation operation)
        {
            RowCollection rows = new RowCollection();

            operation = TableOperation.None;

            // dropped tables
            if (null == updatedTable ^ null == targetTable)
            {
                if (null == targetTable)
                {
                    operation = TableOperation.Add;
                    rows.AddRange(updatedTable.Rows);
                }
                else if (null == updatedTable)
                {
                    operation = TableOperation.Drop;
                }
            }
            else // possibly modified tables
            {
                SortedList updatedPrimaryKeys = new SortedList();
                SortedList targetPrimaryKeys  = new SortedList();

                // compare the table definitions
                if (0 != targetTable.Definition.CompareTo(updatedTable.Definition))
                {
                    // continue to the next table; may be more mismatches
                    this.OnMessage(WixErrors.DatabaseSchemaMismatch(targetOutput.SourceLineNumbers, targetTable.Name));
                }
                else
                {
                    this.IndexPrimaryKeys(targetTable, targetPrimaryKeys, updatedTable, updatedPrimaryKeys);

                    // diff the target and updated rows
                    foreach (DictionaryEntry targetPrimaryKeyEntry in targetPrimaryKeys)
                    {
                        string       targetPrimaryKey = (string)targetPrimaryKeyEntry.Key;
                        bool         keepRow          = false;
                        RowOperation rowOperation     = RowOperation.None;

                        Row compared = this.CompareRows(targetTable, targetPrimaryKeyEntry.Value as Row, updatedPrimaryKeys[targetPrimaryKey] as Row, out rowOperation, out keepRow);

                        if (keepRow)
                        {
                            rows.Add(compared);
                        }
                    }

                    // find the inserted rows
                    foreach (DictionaryEntry updatedPrimaryKeyEntry in updatedPrimaryKeys)
                    {
                        string updatedPrimaryKey = (string)updatedPrimaryKeyEntry.Key;

                        if (!targetPrimaryKeys.Contains(updatedPrimaryKey))
                        {
                            Row updatedRow = (Row)updatedPrimaryKeyEntry.Value;

                            updatedRow.Operation = RowOperation.Add;
                            updatedRow.SectionId = sectionDelimiter + updatedRow.SectionId;
                            rows.Add(updatedRow);
                        }
                    }
                }
            }

            return(rows);
        }
Example #22
0
        /// <summary>
        /// Creates a Row from the XmlReader.
        /// </summary>
        /// <param name="reader">Reader to get data from.</param>
        /// <param name="table">Table for this row.</param>
        /// <returns>New row object.</returns>
        internal static Row Read(XmlReader reader, Table table)
        {
            Debug.Assert("row" == reader.LocalName);

            bool             empty             = reader.IsEmptyElement;
            RowOperation     operation         = RowOperation.None;
            bool             redundant         = false;
            string           sectionId         = null;
            SourceLineNumber sourceLineNumbers = null;

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "op":
                    operation = (RowOperation)Enum.Parse(typeof(RowOperation), reader.Value, true);
                    break;

                case "redundant":
                    redundant = reader.Value.Equals("yes");
                    break;

                case "sectionId":
                    sectionId = reader.Value;
                    break;

                case "sourceLineNumber":
                    sourceLineNumbers = SourceLineNumber.CreateFromEncoded(reader.Value);
                    break;
                }
            }

            var row = table.CreateRow(sourceLineNumbers);

            row.Operation = operation;
            row.Redundant = redundant;
            row.SectionId = sectionId;

            // loop through all the fields in a row
            if (!empty)
            {
                var done  = false;
                var field = 0;

                // loop through all the fields in a row
                while (!done && reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        switch (reader.LocalName)
                        {
                        case "field":
                            if (row.Fields.Length <= field)
                            {
                                if (!reader.IsEmptyElement)
                                {
                                    throw new XmlException();
                                }
                            }
                            else
                            {
                                row.Fields[field].Read(reader);
                            }
                            ++field;
                            break;

                        default:
                            throw new XmlException();
                        }
                        break;

                    case XmlNodeType.EndElement:
                        done = true;
                        break;
                    }
                }

                if (!done)
                {
                    throw new XmlException();
                }
            }

            return(row);
        }
Example #23
0
 public MutationState(int key, RowOperation endType, int minMutations)
 {
     Key          = key;
     EndType      = endType;
     MinMutations = minMutations;
 }
Example #24
0
        /// <summary>
        /// Creates a Row from the XmlReader.
        /// </summary>
        /// <param name="reader">Reader to get data from.</param>
        /// <param name="table">Table for this row.</param>
        /// <returns>New row object.</returns>
        internal static Row Parse(XmlReader reader, Table table)
        {
            Debug.Assert("row" == reader.LocalName);

            bool         empty     = reader.IsEmptyElement;
            RowOperation operation = RowOperation.None;
            string       sectionId = null;
            SourceLineNumberCollection sourceLineNumbers = null;

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "op":
                    switch (reader.Value)
                    {
                    case "add":
                        operation = RowOperation.Add;
                        break;

                    case "delete":
                        operation = RowOperation.Delete;
                        break;

                    case "modify":
                        operation = RowOperation.Modify;
                        break;

                    default:
                        throw new WixException(WixErrors.IllegalAttributeValue(SourceLineNumberCollection.FromUri(reader.BaseURI), "row", reader.Name, reader.Value, "Add", "Delete", "Modify"));
                    }
                    break;

                case "sectionId":
                    sectionId = reader.Value;
                    break;

                case "sourceLineNumber":
                    sourceLineNumbers = new SourceLineNumberCollection(reader.Value);
                    break;

                default:
                    if (!reader.NamespaceURI.StartsWith("http://www.w3.org/", StringComparison.Ordinal))
                    {
                        throw new WixException(WixErrors.UnexpectedAttribute(SourceLineNumberCollection.FromUri(reader.BaseURI), "row", reader.Name));
                    }
                    break;
                }
            }

            Row row = table.CreateRow(sourceLineNumbers);

            row.Operation = operation;
            row.SectionId = sectionId;

            // loop through all the fields in a row
            if (!empty)
            {
                bool done  = false;
                int  field = 0;

                // loop through all the fields in a row
                while (!done && reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        switch (reader.LocalName)
                        {
                        case "field":
                            if (row.Fields.Length <= field)
                            {
                                if (!reader.IsEmptyElement)
                                {
                                    throw new WixException(WixErrors.UnexpectedColumnCount(SourceLineNumberCollection.FromUri(reader.BaseURI), table.Name));
                                }
                            }
                            else
                            {
                                row.fields[field].Parse(reader);
                            }
                            ++field;
                            break;

                        default:
                            throw new WixException(WixErrors.UnexpectedElement(SourceLineNumberCollection.FromUri(reader.BaseURI), "row", reader.Name));
                        }
                        break;

                    case XmlNodeType.EndElement:
                        done = true;
                        break;
                    }
                }

                if (!done)
                {
                    throw new WixException(WixErrors.ExpectedEndElement(SourceLineNumberCollection.FromUri(reader.BaseURI), "row"));
                }
            }

            return(row);
        }
Example #25
0
 public KuduOperation(KuduTable table, RowOperation operation)
     : base(table.Schema, operation)
 {
     Table = table;
 }