Esempio n. 1
0
        public ReflectionEnumerableMessagePackSerializer(
            SerializationContext ownerContext,
            Type targetType,
            CollectionTraits collectionTraits,
            PolymorphismSchema itemsSchema,
            SerializationTarget targetInfo
            )
            : base(ownerContext, itemsSchema, targetInfo.GetCapabilitiesForCollection(collectionTraits))
        {
            if (targetInfo.CanDeserialize)
            {
                this._factory = ReflectionSerializerHelper.CreateCollectionInstanceFactory <TCollection, TItem>(targetInfo.DeserializationConstructor);
                this._addItem = ReflectionSerializerHelper.GetAddItem <TCollection, TItem>(targetType, collectionTraits);
            }
            else
            {
                this._factory = _ => { throw SerializationExceptions.NewCreateInstanceIsNotSupported(targetType); };
                this._addItem = (c, x) => { throw SerializationExceptions.NewUnpackFromIsNotSupported(targetType); };
            }

            this._isPackable   = typeof(IPackable).IsAssignableFrom(targetType ?? typeof(TCollection));
            this._isUnpackable = typeof(IUnpackable).IsAssignableFrom(targetType ?? typeof(TCollection));
#if FEATURE_TAP
            this._isAsyncPackable   = typeof(IAsyncPackable).IsAssignableFrom(targetType ?? typeof(TCollection));
            this._isAsyncUnpackable = typeof(IAsyncUnpackable).IsAssignableFrom(targetType ?? typeof(TCollection));
#endif // FEATURE_TAP
        }
 public ReflectionEnumerableMessagePackSerializer(
     SerializationContext ownerContext,
     Type targetType,
     PolymorphismSchema itemsSchema
     )
     : base(ownerContext, itemsSchema)
 {
     this._factory = ReflectionSerializerHelper.CreateCollectionInstanceFactory <TCollection, TItem>(targetType);
     this._addItem = ReflectionSerializerHelper.GetAddItem <TCollection, TItem>(targetType);
 }
 public ReflectionNonGenericCollectionMessagePackSerializer(
     SerializationContext ownerContext,
     Type abstractType,
     Type concreteType,
     PolymorphismSchema itemsSchema
     )
     : base(ownerContext, abstractType, itemsSchema)
 {
     this._factory = ReflectionSerializerHelper.CreateCollectionInstanceFactory(abstractType, concreteType, typeof(object));
     this._addItem = ReflectionSerializerHelper.GetAddItem(concreteType);
 }
 public ReflectionEnumerableMessagePackSerializer(
     SerializationContext ownerContext,
     Type abstractType,
     Type concreteType,
     CollectionTraits traits,
     PolymorphismSchema itemsSchema
     )
     : base(ownerContext, abstractType, traits, itemsSchema)
 {
     this._factory = ReflectionSerializerHelper.CreateCollectionInstanceFactory(abstractType, concreteType, traits.ElementType);
     this._addItem = ReflectionSerializerHelper.GetAddItem(concreteType);
 }
 public ReflectionNonGenericCollectionMessagePackSerializer(
     SerializationContext ownerContext,
     Type abstractType,
     Type concreteType,
     CollectionTraits concreteTypeCollectionTraits,
     PolymorphismSchema itemsSchema
     )
     : base(ownerContext, abstractType, itemsSchema)
 {
     this._factory      = ReflectionSerializerHelper.CreateCollectionInstanceFactory(abstractType, concreteType, typeof(object));
     this._addItem      = ReflectionSerializerHelper.GetAddItem(concreteType, concreteTypeCollectionTraits);
     this._isPackable   = typeof(IPackable).IsAssignableFrom(concreteType ?? abstractType);
     this._isUnpackable = typeof(IUnpackable).IsAssignableFrom(concreteType ?? abstractType);
 }
        public ReflectionEnumerableMessagePackSerializer(
            SerializationContext ownerContext,
            Type targetType,
            CollectionTraits collectionTraits,
            PolymorphismSchema itemsSchema
            )
            : base(ownerContext, itemsSchema)
        {
            this._factory      = ReflectionSerializerHelper.CreateCollectionInstanceFactory <TCollection, TItem>(targetType);
            this._addItem      = ReflectionSerializerHelper.GetAddItem <TCollection, TItem>(targetType, collectionTraits);
            this._isPackable   = typeof(IPackable).IsAssignableFrom(targetType ?? typeof(TCollection));
            this._isUnpackable = typeof(IUnpackable).IsAssignableFrom(targetType ?? typeof(TCollection));
#if FEATURE_TAP
            this._isAsyncPackable   = typeof(IAsyncPackable).IsAssignableFrom(targetType ?? typeof(TCollection));
            this._isAsyncUnpackable = typeof(IAsyncUnpackable).IsAssignableFrom(targetType ?? typeof(TCollection));
#endif // FEATURE_TAP
        }
Esempio n. 7
0
        public ReflectionEnumerableMessagePackSerializer(
            SerializationContext ownerContext,
            Type abstractType,
            Type concreteType,
            CollectionTraits concreteTypeCollectionTraits,
            PolymorphismSchema itemsSchema,
            SerializationTarget targetInfo
            )
            : base(ownerContext, abstractType, concreteTypeCollectionTraits, itemsSchema, targetInfo.GetCapabilitiesForCollection(concreteTypeCollectionTraits))
        {
            if (targetInfo.CanDeserialize)
            {
                this._factory = ReflectionSerializerHelper.CreateCollectionInstanceFactory(abstractType, concreteType, concreteTypeCollectionTraits.ElementType, targetInfo.DeserializationConstructor);
                this._addItem = ReflectionSerializerHelper.GetAddItem(concreteType, concreteTypeCollectionTraits);
            }
            else
            {
                this._factory = _ => { throw SerializationExceptions.NewCreateInstanceIsNotSupported(concreteType); };
                this._addItem = (c, x) => { throw SerializationExceptions.NewUnpackFromIsNotSupported(concreteType); };
            }

            this._isPackable   = typeof(IPackable).IsAssignableFrom(concreteType ?? abstractType);
            this._isUnpackable = typeof(IUnpackable).IsAssignableFrom(concreteType ?? abstractType);
        }