コード例 #1
0
        public static void AvoidLinkedListStackOverflow()
        {
            var value          = PersistentList.Of(Enumerable.Range(0, 3000));
            var typeConverters = new[] { PersistentListTypeConverter.Instance };
            var clone          = BinarySerialisationCloner.Clone(value, typeConverters, typeConverters, ReferenceReuseOptions.SupportReferenceReUseInMostlyTreeLikeStructure);

            Assert.Equal(value.ToArray(), clone.ToArray());
        }
コード例 #2
0
 public static void DoNotTryToGenerateMemberSettersForConvertedTypes() => AssertCanGenerateCorrectMemberSetter(
     new SomethingWithImmutableListProperty {
     Roles = PersistentList.Of(new[] { "abc", "def" })
 },
     new[] { ImmutableListTypeConverter.Instance },                 // Use ImmutableListTypeConverter instead of PersistentListTypeConverter because the latter doesn't implement IFastSerialisationTypeConverter
     expectedNumberOfMemberSettersGenerated: 2,
     expectedNumberOfMemberSettersThatCanNotBeGenerated: 0
     );
コード例 #3
0
        private static object ConvertIfRequired <T>(object value, Type targetTypeIfDeserialising)
        {
            if (value != null)
            {
                // If targetTypeIfDeserialising is null then this is a ConvertIfRequired during serialisation
                if (targetTypeIfDeserialising == null)
                {
                    return(((value is PersistentList <T> list)) ? list.ToArray() : value);
                }

                if (targetTypeIfDeserialising == typeof(PersistentList <T>))
                {
                    return(((value is IEnumerable <T> enumerable)) ? PersistentList.Of(enumerable) : value);
                }
            }
            return(value);
        }
コード例 #4
0
 protected override IEnumerable <T> GetList <T>(T[] valuesIfAny) => (valuesIfAny == null) ? null : PersistentList.Of(valuesIfAny);