Пример #1
0
 public static ReflectionEmitUtils.GetterMethod GenerateGetter(FieldInfo fieldInfo)
 {
     return(ReflectionEmitUtils.GenerateGetter(fieldInfo.FieldType, fieldInfo.DeclaringType, delegate(ILGenerator il)
     {
         il.Emit(OpCodes.Ldfld, fieldInfo);
     }));
 }
Пример #2
0
 public static ReflectionEmitUtils.GetterMethod GenerateGetter(PropertyInfo propertyInfo)
 {
     return(ReflectionEmitUtils.GenerateGetter(propertyInfo.PropertyType, propertyInfo.DeclaringType, delegate(ILGenerator il)
     {
         MethodInfo getMethod = propertyInfo.GetGetMethod(true);
         il.Emit(OpCodes.Callvirt, getMethod);
     }));
 }
 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);
 }
Пример #5
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);
        }