Beispiel #1
0
        private static void InitializeSerialization()
        {
            var conventions = new ConventionProfile();

            conventions.SetDefaultValueConvention(new EmptyGuidDefaultValueConvention());
            conventions.SetSerializeDefaultValueConvention(new NeverSerializeDefaultValueConvention());
            BsonClassMap.RegisterConventions(conventions, type => type.FullName.StartsWith("MongoDB.BsonUnitTests.Jira.CSharp310Tests"));
        }
Beispiel #2
0
        private static void InitializeSerialization()
        {
            var conventions = new ConventionProfile();

            conventions.SetDefaultValueConvention(new EmptyGuidDefaultValueConvention());
#pragma warning disable 618 // SetSerializeDefaultValueConvention and NeverSerializeDefaultValueConvention are obsolete
            conventions.SetSerializeDefaultValueConvention(new NeverSerializeDefaultValueConvention());
#pragma warning restore 618
            BsonClassMap.RegisterConventions(conventions, type => type.FullName.StartsWith("MongoDB.BsonUnitTests.Jira.CSharp310Tests", StringComparison.Ordinal));
        }
Beispiel #3
0
        public void AfterPropertiesSet()
        {
            var defaultProfile = ConventionProfile.GetDefault();

            _profile = new ConventionProfile();
            _filter  = new ConventionFilterHelper(IncludeFilters, ExcludeFilters);

            _profile.SetDefaultValueConvention(DefaultValueConvention ?? defaultProfile.DefaultValueConvention);
            _profile.SetElementNameConvention(ElementNameConvention ?? defaultProfile.ElementNameConvention);
            _profile.SetExtraElementsMemberConvention(ExtraElementsMemberConvention ?? defaultProfile.ExtraElementsMemberConvention);
            _profile.SetIdGeneratorConvention(IdGeneratorConvention ?? defaultProfile.IdGeneratorConvention);
            _profile.SetIdMemberConvention(IdMemberConvention ?? defaultProfile.IdMemberConvention);
            _profile.SetIgnoreExtraElementsConvention(IgnoreExtraElementsConvention ?? defaultProfile.IgnoreExtraElementsConvention);
            _profile.SetIgnoreIfDefaultConvention(IgnoreIfDefaultConvention ?? defaultProfile.IgnoreIfDefaultConvention);
            _profile.SetIgnoreIfNullConvention(IgnoreIfNullConvention ?? defaultProfile.IgnoreIfNullConvention);
            _profile.SetMemberFinderConvention(MemberFinderConvention ?? defaultProfile.MemberFinderConvention);
            _profile.SetSerializationOptionsConvention(SerializationOptionsConvention ?? defaultProfile.SerializationOptionsConvention);

            BsonClassMap.RegisterConventions(_profile, _filter.Filter);
        }