Ejemplo n.º 1
0
            private static int FindIndex(TTargetData[] collectionToLookIn, TTargetData objectToFind, IEqualityComparer <TTargetData> equalityComparer)
            {
                for (var i = 0; i < collectionToLookIn.Length; i++)
                {
                    TTargetData targetData = collectionToLookIn[i];
                    if (targetData != null && equalityComparer.Equals(targetData, objectToFind))
                    {
                        return(i);
                    }
                }

                return(-1);
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Gets a collection of updated objects from the existing object collection and the
            /// added objects from the imported object collection in the same order that was
            /// found in the imported object collection.
            /// </summary>
            /// <returns>An ordered collection of updated and added elements.</returns>
            public IEnumerable <TTargetData> GetModifiedCollection()
            {
                KeyValuePair <int, TTargetData>[] remainingObjects = ObjectsToBeUpdated.Union(ObjectsToBeAdded).ToArray();

                var orderedObjects = new TTargetData[remainingObjects.Length];

                foreach (KeyValuePair <int, TTargetData> remainingObject in remainingObjects)
                {
                    orderedObjects[remainingObject.Key] = remainingObject.Value;
                }

                return(orderedObjects);
            }