Exemple #1
0
        void ISetPropertyBagVisitor.Visit <TSet, TValue>(ISetPropertyBag <TSet, TValue> properties, ref TSet container)
        {
            m_Stream->Add(container.Count);

            foreach (var value in container)
            {
                WriteValue(value);
            }
        }
        void ISetPropertyBagVisitor.Visit <TSet, TValue>(ISetPropertyBag <TSet, TValue> properties, ref TSet container)
        {
            m_SerializedReferences?.AddDeserializedReference(container);

            container.Clear();
            var count = m_Stream->ReadNext <int>();

            for (var i = 0; i < count; i++)
            {
                container.Add(ReadValue <TValue>());
            }
        }
        /// <summary>
        /// Invoked by Unity.Properties for each set container type. (i.e. ISet type)
        /// </summary>
        /// <param name="properties">The property bag being visited.</param>
        /// <param name="srcContainer">The source set being visited.</param>
        /// <typeparam name="TSet">The set type.</typeparam>
        /// <typeparam name="TElement">The element type.</typeparam>
        void ISetPropertyBagVisitor.Visit <TSet, TElement>(ISetPropertyBag <TSet, TElement> properties, ref TSet srcContainer)
        {
            // Unbox the current destination container being written to.
            var dstContainer = (TSet)m_Stack;

            dstContainer.Clear();

            foreach (var element in srcContainer)
            {
                var value = default(TElement);
                CloneValue(ref value, element);
                dstContainer.Add(value);
            }

            // Re-box the container.
            m_Stack = dstContainer;
        }
Exemple #4
0
        void ISetPropertyBagVisitor.Visit <TSet, TElement>(ISetPropertyBag <TSet, TElement> properties, ref TSet container)
        {
            var elements = m_Metadata.HasElements ? m_View.AsObjectView()[k_SerializedElementsKey] : m_View;

            if (elements.Type != TokenType.Array)
            {
                throw new ArgumentException();
            }

            var arr = elements.AsArrayView();

            container.Clear();

            foreach (var element in arr)
            {
                var value = default(TElement);
                ReadValue(ref value, element);
                container.Add(value);
            }
        }
Exemple #5
0
        /// <summary>
        /// Invoked by Unity.Properties for each set container type. (i.e. ISet type)
        /// </summary>
        /// <param name="properties">The property bag being visited.</param>
        /// <param name="srcContainer">The source set being visited.</param>
        /// <typeparam name="TSet">The set type.</typeparam>
        /// <typeparam name="TElement">The element type.</typeparam>
        void ISetPropertyBagVisitor.Visit <TSet, TElement>(ISetPropertyBag <TSet, TElement> properties, ref TSet srcContainer)
        {
            var dstContainer = (TSet)m_Stack;

            if (srcContainer.Count != dstContainer.Count)
            {
                m_Equals = false;
                return;
            }

            using (var srcContainerEnumerator = srcContainer.GetEnumerator())
                using (var dstContainerEnumerator = dstContainer.GetEnumerator())
                {
                    for (;;)
                    {
                        var srcNext = srcContainerEnumerator.MoveNext();
                        var dstNext = dstContainerEnumerator.MoveNext();

                        if (srcNext != dstNext)
                        {
                            m_Equals = false;
                            return;
                        }

                        if (!srcNext)
                        {
                            break;
                        }

                        if (CompareEquality(srcContainerEnumerator.Current, dstContainerEnumerator.Current))
                        {
                            continue;
                        }
                        m_Equals = false;
                        return;
                    }
                }
        }