Beispiel #1
0
 protected internal override void Initialize(IntermediateSerializer serializer)
 {
     this.keySerializer           = serializer.GetTypeSerializer(typeof(Key));
     this.valueSerializer         = serializer.GetTypeSerializer(typeof(Value));
     this.keyFormat               = new ContentSerializerAttribute();
     this.valueFormat             = new ContentSerializerAttribute();
     this.keyFormat.ElementName   = "Key";
     this.valueFormat.ElementName = "Value";
     this.keyFormat.AllowNull     = false;
     if (typeof(Value).IsValueType)
     {
         this.valueFormat.AllowNull = false;
     }
 }
        protected internal override void Initialize(IntermediateSerializer serializer)
        {
            if (base.TargetType.BaseType != null)
            {
                this.baseSerializer = serializer.GetTypeSerializer(base.TargetType.BaseType);
            }
            MemberHelperBase <IntermediateSerializer> .CreateMemberHelpers <ReflectiveSerializerMemberHelper>(serializer, base.TargetType, this.memberHelpers);

            if (CollectionUtils.IsCollection(base.TargetType, false))
            {
                this.collectionHelper = serializer.GetCollectionHelper(base.TargetType);
            }
            object[] customAttributes = base.TargetType.GetCustomAttributes(typeof(ContentSerializerCollectionItemNameAttribute), true);
            if (customAttributes.Length == 1)
            {
                this.collectionItemName = ((ContentSerializerCollectionItemNameAttribute)customAttributes[0]).CollectionItemName;
            }
        }
Beispiel #3
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);
        }
 protected internal override void Initialize(IntermediateSerializer serializer)
 {
     this.underlyingTypeSerializer        = serializer.GetTypeSerializer(typeof(T));
     this.underlyingFormat                = new ContentSerializerAttribute();
     this.underlyingFormat.FlattenContent = true;
 }