/// <summary> /// Constructs a new <see cref="DotNetSerializableSurrogate"/>. /// </summary> /// <param name="context"><see cref="FudgeContext"/> to use.</param> /// <param name="typeData"><see cref="TypeData"/> for the type for this surrogate.</param> public DotNetSerializableSurrogate(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", "DotNetSerializableSurrogate cannot handle " + typeData.Type.FullName); this.context = context; this.type = typeData.Type; this.constructor = FindConstructor(typeData); helper = new SerializationInfoMixin(context, typeData.Type, new BeforeAfterSerializationMixin(context, typeData)); }
/// <summary> /// Constructs a new <see cref="DotNetSerializationSurrogateSurrogate"/>. /// </summary> /// <param name="context"><see cref="FudgeContext"/> to use.</param> /// <param name="typeData"><see cref="TypeData"/> for the type for this surrogate.</param> /// <param name="surrogate">Surrogate that maps the object to or from a <see cref="SerializationInfo"/>.</param> /// <param name="selector">Selector that produced the surrogate.</param> public DotNetSerializationSurrogateSurrogate(FudgeContext context, TypeData typeData, ISerializationSurrogate surrogate, ISurrogateSelector selector) { if (context == null) throw new ArgumentNullException("context"); if (typeData == null) throw new ArgumentNullException("typeData"); if (surrogate == null) throw new ArgumentNullException("surrogate"); // Don't care if selector is null this.helper = new SerializationInfoMixin(context, typeData.Type, new BeforeAfterSerializationMixin(context, typeData)); this.surrogate = surrogate; this.selector = selector; }