Esempio n. 1
0
        /// <summary>
        /// Prepares operation for every descendant index of target array.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <returns>Array where the input arrays is merged into.</returns>
        private void mergeArrays(MergeOperation operation)
        {
            AssociativeArray    targetArray      = Structure.Readonly.GetArray(operation.TargetIndex);
            IArrayDescriptor    targetDescriptor = Structure.Readonly.GetDescriptor(targetArray);
            ContainerOperations collectIndexes   = new ContainerOperations(this, targetDescriptor, operation.TargetIndex, targetDescriptor.UnknownIndex);

            foreach (var operationData in operation.Indexes)
            {
                MemoryIndex index    = operationData.Item1;
                Snapshot    snapshot = operationData.Item2;

                AssociativeArray arrayValue;
                if (snapshot.Structure.Readonly.TryGetArray(index, out arrayValue))
                {
                    IArrayDescriptor descriptor = snapshot.Structure.Readonly.GetDescriptor(arrayValue);
                    collectIndexes.AddContainer(descriptor, snapshot);
                }
                else
                {
                    collectIndexes.SetUndefined();
                }
            }

            collectIndexes.MergeContainers();
        }
Esempio n. 2
0
        /// <summary>
        /// Creates the merge operation for all fields of specified object.
        /// </summary>
        /// <param name="objectValue">The object value.</param>
        private void mergeObject(ObjectValue objectValue)
        {
            IObjectDescriptor   targetDescriptor = Structure.Readonly.GetDescriptor(objectValue);
            ContainerOperations collectVariables = new ContainerOperations(this, targetDescriptor, targetDescriptor.UnknownIndex, targetDescriptor.UnknownIndex);

            foreach (Snapshot snapshot in sourceSnapshots)
            {
                IObjectDescriptor descriptor;
                if (snapshot.Structure.Readonly.TryGetDescriptor(objectValue, out descriptor))
                {
                    collectVariables.AddContainer(descriptor, snapshot);
                }
                else
                {
                    collectVariables.SetUndefined();
                }
            }

            collectVariables.MergeContainers();
        }