Пример #1
0
        /// <summary>
        /// Processes the index - traverse thru array or sets path to undefined.
        /// </summary>
        /// <param name="parentIndex">Index of the parent.</param>
        /// <param name="indexSegment">The index segment.</param>
        /// <param name="visitor">The visitor to process scalar values.</param>
        private void processIndex(MemoryIndex parentIndex, IndexPathSegment indexSegment, ProcessValueAsLocationVisitor visitor)
        {
            MemoryEntry entry;

            if (snapshot.Data.Readonly.TryGetMemoryEntry(parentIndex, out entry))
            {
                bool             processOtherValues = false;
                AssociativeArray arrayValue;
                if (snapshot.Structure.Readonly.TryGetArray(parentIndex, out arrayValue))
                {
                    IArrayDescriptor descriptor = snapshot.Structure.Readonly.GetDescriptor(arrayValue);
                    process(indexSegment, descriptor);

                    processOtherValues = entry.Count > 1;
                }
                else if (entry.Count > 0)
                {
                    processOtherValues = true;
                }
                else
                {
                    IsDefined = false;
                }

                if (processOtherValues)
                {
                    visitor.ProcessValues(parentIndex, entry.PossibleValues, true);
                }
            }
            else
            {
                IsDefined = false;
            }
        }
Пример #2
0
        /// <summary>
        /// Processes the field - traverse thru all containing objects or sets path to undefined.
        /// </summary>
        /// <param name="parentIndex">Index of the parent.</param>
        /// <param name="fieldSegment">The field segment.</param>
        /// <param name="visitor">The visitor to process scalar values.</param>
        private void processField(MemoryIndex parentIndex, FieldPathSegment fieldSegment, ProcessValueAsLocationVisitor visitor)
        {
            MemoryEntry entry;

            if (snapshot.Data.Readonly.TryGetMemoryEntry(parentIndex, out entry))
            {
                bool processOtherValues            = false;
                IObjectValueContainer objectValues = snapshot.Structure.Readonly.GetObjects(parentIndex);
                if (objectValues.Count > 0)
                {
                    foreach (ObjectValue objectValue in objectValues)
                    {
                        IObjectDescriptor descriptor = snapshot.Structure.Readonly.GetDescriptor(objectValue);
                        process(fieldSegment, descriptor);
                    }

                    processOtherValues = entry.Count > objectValues.Count;
                }
                else if (entry.Count > 0)
                {
                    processOtherValues = true;
                }
                else
                {
                    IsDefined = false;
                }

                if (processOtherValues)
                {
                    visitor.ProcessValues(parentIndex, entry.PossibleValues, true);
                }
            }
            else
            {
                IsDefined = false;
            }
        }