コード例 #1
0
        /// <inheritdoc />
        protected override object GetCollectionValue(IEnumerable collection, int collectionIndex)
        {
            int current = 0;

            foreach (var item in collection)
            {
                if (current == collectionIndex)
                {
                    return(item);
                }
                current++;
            }
            return(MemberType.DefaultValue());
        }
コード例 #2
0
        /// <inheritdoc />
        protected override void SetCollectionValue(ref IDictionary collection, int collectionIndex, [NotNull] object dictionaryEntry)
        {
                        #if DEV_MODE && PI_ASSERTATIONS
            Debug.Assert(dictionaryEntry != null, "SetCollectionValue(" + StringUtils.ToString(dictionaryEntry) + "<" + StringUtils.TypeToString(dictionaryEntry) + ">, " + collectionIndex + ") called with null dictionaryEntry\nMemberType=" + StringUtils.ToString(MemberType) + ", MemberType.DefaultValue()=" + StringUtils.ToString(MemberType.DefaultValue()));
                        #endif

            var set = (DictionaryEntry)dictionaryEntry;

            var key   = set.Key;
            var value = set.Value;

                        #if DEV_MODE
            Debug.Assert(key != null, "getDictionaryEntryKey(" + StringUtils.ToString(dictionaryEntry) + "<" + StringUtils.TypeToString(dictionaryEntry) + ">) returned null\nMemberType=" + StringUtils.ToString(MemberType) + ", MemberType.DefaultValue()=" + StringUtils.ToString(MemberType.DefaultValue()));
                        #endif

            //collectionIndex is ignored at least for now
            //to try and keep the order right, could theoretically rebuild the dictionary again from scratch,
            //placing items inside it in the same order as before?
            collection[key] = value;
        }