/// <summary> /// Initializes a new instance of the <see cref="ValueMapping"/> struct. /// </summary> /// <param name="encoder">The encoder.</param> internal ValueMapping(IMessagePartEncoder encoder) { Contract.Requires <ArgumentNullException>(encoder != null); var nullEncoder = encoder as IMessagePartNullEncoder; string nullString = nullEncoder != null ? nullEncoder.EncodedNullValue : null; this.ValueToString = obj => (obj != null) ? encoder.Encode(obj) : nullString; this.StringToValue = str => (str != null) ? encoder.Decode(str) : null; }
/// <summary> /// Initializes a new instance of the <see cref="ValueMapping"/> struct. /// </summary> /// <param name="encoder">The encoder.</param> internal ValueMapping(IMessagePartEncoder encoder) { ErrorUtilities.VerifyArgumentNotNull(encoder, "encoder"); var nullEncoder = encoder as IMessagePartNullEncoder; string nullString = nullEncoder != null ? nullEncoder.EncodedNullValue : null; this.ValueToString = obj => (obj != null) ? encoder.Encode(obj) : nullString; this.StringToValue = str => (str != null) ? encoder.Decode(str) : null; }
/// <summary> /// Initializes a new instance of the <see cref="ValueMapping"/> struct. /// </summary> /// <param name="encoder">The encoder.</param> internal ValueMapping(IMessagePartEncoder encoder) { Requires.NotNull(encoder, "encoder"); var nullEncoder = encoder as IMessagePartNullEncoder; string nullString = nullEncoder != null ? nullEncoder.EncodedNullValue : null; var originalStringEncoder = encoder as IMessagePartOriginalEncoder; Func<object, string> originalStringEncode = encoder.Encode; if (originalStringEncoder != null) { originalStringEncode = originalStringEncoder.EncodeAsOriginalString; } this.ValueToString = obj => (obj != null) ? encoder.Encode(obj) : nullString; this.StringToValue = str => (str != null) ? encoder.Decode(str) : null; this.ValueToOriginalString = obj => (obj != null) ? originalStringEncode(obj) : nullString; }
public ValueMapping(IMessagePartEncoder encoder) : this() { this.Encoder = encoder; var nullEncoder = encoder as IMessagePartNullEncoder; string nullString = nullEncoder != null ? nullEncoder.EncodedNullValue : null; var originalStringEncoder = encoder as IMessagePartOriginalEncoder; Func <object, string> originalStringEncode = encoder.Encode; if (originalStringEncoder != null) { originalStringEncode = originalStringEncoder.EncodeAsOriginalString; } this.ValueToString = obj => (obj != null) ? encoder.Encode(obj) : nullString; this.StringToValue = str => (str != null) ? encoder.Decode(str) : null; this.ValueToOriginalString = obj => (obj != null) ? originalStringEncode(obj) : nullString; }
/// <summary> /// Initializes a new instance of the <see cref="ValueMapping"/> struct. /// </summary> /// <param name="encoder">The encoder.</param> internal ValueMapping(IMessagePartEncoder encoder) { Contract.Requires <ArgumentNullException>(encoder != null); var nullEncoder = encoder as IMessagePartNullEncoder; string nullString = nullEncoder != null ? nullEncoder.EncodedNullValue : null; var originalStringEncoder = encoder as IMessagePartOriginalEncoder; Func <object, string> originalStringEncode = encoder.Encode; if (originalStringEncoder != null) { originalStringEncode = originalStringEncoder.EncodeAsOriginalString; } this.ValueToString = obj => (obj != null) ? encoder.Encode(obj) : nullString; this.StringToValue = str => (str != null) ? encoder.Decode(str) : null; this.ValueToOriginalString = obj => (obj != null) ? originalStringEncode(obj) : nullString; }