/// <summary>
        /// Constructs a new <see cref="SerializableAttributeSurrogate"/>.
        /// </summary>
        /// <param name="context"><see cref="FudgeContext"/> to use.</param>
        /// <param name="typeData"><see cref="TypeData"/> for the type for this surrogate.</param>
        public SerializableAttributeSurrogate(FudgeContext context, TypeData typeData)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (typeData == null)
            {
                throw new ArgumentNullException("typeData");
            }
            if (!CanHandle(typeData))
            {
                throw new ArgumentOutOfRangeException("typeData", "SerializableAttributeSurrogate cannot handle " + typeData.Type.FullName);
            }

            this.type = typeData.Type;

            var fields = from field in typeData.Fields
                         where field.GetCustomAttribute <NonSerializedAttribute>() == null
                         select field;

            var beforeAfterMixin = new DotNetSerializableSurrogate.BeforeAfterMethodMixin(context, typeData);

            this.serializerMixin = new PropertyBasedSerializationSurrogate.PropertySerializerMixin(context, typeData, fields, beforeAfterMixin);
        }
Example #2
0
            public PropertySerializerMixin(FudgeContext context, TypeData typeData, IEnumerable <TypeData.PropertyData> properties, DotNetSerializableSurrogate.BeforeAfterMethodMixin beforeAfterMethodHelper)
            {
                this.context  = context;
                this.typeData = typeData;
                this.beforeAfterMethodHelper = beforeAfterMethodHelper;

                ExtractProperties(properties);
            }