Beispiel #1
0
        private static ImpliedImplementationInterfaceSerializer <IList <T>, List <T> > ListOfInterfacesSerializer <T, TI>() where TI : class, T
        {
            var serializer     = new ImpliedImplementationInterfaceSerializer <T, TI>();
            var listSerializer = new EnumerableInterfaceImplementerSerializer <List <T>, T>(serializer);

            return(new ImpliedImplementationInterfaceSerializer <IList <T>, List <T> >(listSerializer));
        }
Beispiel #2
0
 public static void AvoidAOT()
 {
     ArraySerializer <int>    aint    = new ArraySerializer <int>();
     ArraySerializer <string> astring = new ArraySerializer <string>();
     ArraySerializer <long>   along   = new ArraySerializer <long>();
     EnumerableInterfaceImplementerSerializer <List <int> >     e        = new EnumerableInterfaceImplementerSerializer <List <int> >();
     EnumerableInterfaceImplementerSerializer <List <int>, int> elistint = new EnumerableInterfaceImplementerSerializer <List <int>, int>();
 }
Beispiel #3
0
        private IBsonSerializer <C> CreateSubject()
        {
            // create subject without using the global serializer registry
            var serializerRegistry = new BsonSerializerRegistry();
            var subject            = new EnumerableInterfaceImplementerSerializer <C, C>(serializerRegistry);

            serializerRegistry.RegisterSerializer(typeof(C), subject);
            return(subject);
        }
        public static void RegisterClassMaps()
        {
            BsonSerializer.RegisterGenericSerializerDefinition(typeof(ISet <>), typeof(SetSerializer <>));
            BsonSerializer.RegisterSerializer(new JobDataMapSerializer());

            BsonClassMap.RegisterClassMap <Key <JobKey> >(map =>
            {
                map.AutoMap();
                map.MapProperty(key => key.Group);
                map.MapProperty(key => key.Name);
                map.AddKnownType(typeof(JobKey));
            });
            BsonClassMap.RegisterClassMap <Key <TriggerKey> >(map =>
            {
                map.AutoMap();
                map.MapProperty(key => key.Group);
                map.MapProperty(key => key.Name);
                map.AddKnownType(typeof(TriggerKey));
            });
            BsonClassMap.RegisterClassMap <JobKey>(map =>
            {
                map.MapCreator(jobKey => new JobKey(jobKey.Name));
                map.MapCreator(jobKey => new JobKey(jobKey.Name, jobKey.Group));
            });

            BsonClassMap.RegisterClassMap <TriggerKey>(map =>
            {
                map.MapCreator(triggerKey => new TriggerKey(triggerKey.Name));
                map.MapCreator(triggerKey => new TriggerKey(triggerKey.Name, triggerKey.Group));
            });
            BsonClassMap.RegisterClassMap <TimeOfDay>(map =>
            {
                map.AutoMap();
                map.MapProperty(day => day.Hour);
                map.MapProperty(day => day.Minute);
                map.MapProperty(day => day.Second);
                map.MapCreator(day => new TimeOfDay(day.Hour, day.Minute, day.Second));
                map.MapCreator(day => new TimeOfDay(day.Hour, day.Minute));
            });

            BsonClassMap.RegisterClassMap <JobDetail>(map =>
            {
                map.AutoMap();
                map.MapProperty(detail => detail.JobType).SetSerializer(new TypeSerializer());
            });

            BsonClassMap.RegisterClassMap <DailyTimeIntervalTrigger>(map =>
            {
                map.AutoMap();
                var serializer =
                    new EnumerableInterfaceImplementerSerializer
                    <System.Collections.Generic.HashSet <DayOfWeek>, DayOfWeek>(
                        new EnumSerializer <DayOfWeek>(BsonType.String));
                map.MapProperty(trigger => trigger.DaysOfWeek).SetSerializer(serializer);
            });
        }
            public TestDocumentClassSerializer()
            {
                var itemSerializer = new Int32Serializer(BsonType.String);
                var listSerializer = new EnumerableInterfaceImplementerSerializer <List <int> >(itemSerializer);

                this.RegisterMember("Id", "_id", new ObjectIdSerializer());
                this.RegisterMember("Name", "name", new StringSerializer());
                this.RegisterMember("Colors", "colors", listSerializer);
                this.RegisterMember("Colors2", "colors2", listSerializer);
            }