Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CopyWithinSnapshotWorker"/> class.
        /// </summary>
        /// <param name="snapshot">The snapshot.</param>
        /// <param name="isMust">if set to <c>true</c> [is must].</param>
        public CopyWithinSnapshotWorker(Snapshot snapshot, bool isMust)
        {
            this.snapshot = snapshot;
            this.isMust   = isMust;

            AliasState = CopyAliasState.OnlyAliases;
        }
Beispiel #2
0
        /// <summary>
        /// Processes the array value - create new copy of this level of memory tree.
        /// </summary>
        /// <param name="targetIndex">Index of the target.</param>
        /// <param name="value">The value.</param>
        /// <returns>Array value which should be inserted into target location.</returns>
        internal AssociativeArray ProcessArrayValue(MemoryIndex targetIndex, AssociativeArray value)
        {
            AssociativeArray arrayValue = snapshot.CreateArray(targetIndex, isMust);

            ArrayDescriptor sourceDescriptor = snapshot.Structure.GetDescriptor(value);
            ArrayDescriptor targetDescriptor = snapshot.Structure.GetDescriptor(arrayValue);

            CopyAliasState oldState = AliasState;

            AliasState = CopyAliasState.OnlyAliases;
            Copy(sourceDescriptor.UnknownIndex, targetDescriptor.UnknownIndex);

            AliasState = CopyAliasState.LinkWithIndex;
            foreach (var index in sourceDescriptor.Indexes)
            {
                MemoryIndex newIndex = snapshot.CreateIndex(index.Key, arrayValue, false, false);
                Copy(index.Value, newIndex);
            }

            AliasState = oldState;
            return(arrayValue);
        }