protected override void Initialize(IntermediateSerializer serializer, PropertyInfo propertyInfo)
 {
     this.valueGetter = ReflectionEmitUtils.GenerateGetter(propertyInfo);
     if (propertyInfo.CanWrite)
     {
         this.valueSetter = ReflectionEmitUtils.GenerateSetter(propertyInfo);
     }
     this.InitializeCommon(serializer, propertyInfo, propertyInfo.PropertyType);
 }
 protected override void Initialize(IntermediateSerializer serializer, FieldInfo fieldInfo, bool canWrite)
 {
     this.valueGetter = ReflectionEmitUtils.GenerateGetter(fieldInfo);
     if (canWrite)
     {
         this.valueSetter = ReflectionEmitUtils.GenerateSetter(fieldInfo);
     }
     this.InitializeCommon(serializer, fieldInfo, fieldInfo.FieldType);
 }
 internal CollectionHelper(IntermediateSerializer serializer, Type type)
 {
     this.targetType = type;
     Type type2 = CollectionUtils.CollectionElementType(type, false);
     if (type2 == null)
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.NotACollectionType, new object[]
         {
             type
         }));
     }
     this.contentSerializer = serializer.GetTypeSerializer(type2);
     Type type3 = typeof(ICollection<>).MakeGenericType(new Type[]
     {
         type2
     });
     this.countPropertyGetter = ReflectionEmitUtils.GenerateGetter(type3.GetProperty("Count"));
     this.addToCollection = ReflectionEmitUtils.GenerateAddToCollection(type3, type2);
 }
Example #4
0
        internal CollectionHelper(IntermediateSerializer serializer, Type type)
        {
            this.targetType = type;
            Type type2 = CollectionUtils.CollectionElementType(type, false);

            if (type2 == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.NotACollectionType, new object[]
                {
                    type
                }));
            }
            this.contentSerializer = serializer.GetTypeSerializer(type2);
            Type type3 = typeof(ICollection <>).MakeGenericType(new Type[]
            {
                type2
            });

            this.countPropertyGetter = ReflectionEmitUtils.GenerateGetter(type3.GetProperty("Count"));
            this.addToCollection     = ReflectionEmitUtils.GenerateAddToCollection(type3, type2);
        }