コード例 #1
0
ファイル: ValueMapping.cs プロジェクト: qbhoy88/dotnetopenid
        /// <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;
        }
コード例 #2
0
ファイル: ValueMapping.cs プロジェクト: jcp-xx/dotnetopenid
        /// <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;
        }
コード例 #3
0
		/// <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;
		}
コード例 #4
0
        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;
        }
コード例 #5
0
ファイル: ValueMapping.cs プロジェクト: thild/dotnetopenid
        /// <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;
        }