public IFormatter Create(Type type) { Type formatterType = typeof(EditableFormatter <>).MakeGenericType(type); IEditableFormatter formatter = Activator.CreateInstance(formatterType) as IEditableFormatter; formatter.SerializationDelegate = CreateWriteMethod(type); formatter.DeserializationDelegate = CreateReadMethod(type); formatter.ShouldSkipFieldDelegate = CreateShouldSkipMethod(type); return(formatter as IFormatter); }
public IFormatter BuildFormatter() { Initialize(); CreateSerializeMethod(); CreateDeserializeMethod(); CreateShouldSkipMethod(); IEditableFormatter editableFormatter = Activator.CreateInstance(typeof(EditableFormatter <>).MakeGenericType(TargetType)) as IEditableFormatter; editableFormatter.DeserializationDelegate = DeserializeExpression.Compile(); editableFormatter.SerializationDelegate = SerializeExpression.Compile(); editableFormatter.ShouldSkipFieldDelegate = ShouldSkipExpression.Compile(); return(editableFormatter as IFormatter); }