コード例 #1
0
 /// <summary>
 /// Gets a Func for creating <see cref="ITypeTranscoder"/> transcoders.
 /// </summary>
 /// <param name="config">The current <see cref="ClientConfiguration"/>.</param>
 /// <param name="element">The <see cref="TranscoderElement"/> from the App.Config or Web.Config.</param>
 /// <returns>A <see cref="Func{ITypeTranscoder}"/> for creating <see cref="ITypeTranscoder"/>s.</returns>
 public static Func <ITypeTranscoder> GetTranscoder(ClientConfiguration config, TranscoderElement element)
 {
     return(GetTranscoder(config, element.Type));
 }
コード例 #2
0
        /// <summary>
        /// Gets a Func for creating <see cref="ITypeTranscoder"/> transcoders.
        /// </summary>
        /// <param name="config">The current <see cref="ClientConfiguration"/>.</param>
        /// <param name="element">The <see cref="TranscoderElement"/> from the App.Config or Web.Config.</param>
        /// <returns>A <see cref="Func{ITypeTranscoder}"/> for creating <see cref="ITypeTranscoder"/>s.</returns>
        public static Func <ITypeTranscoder> GetTranscoder(ClientConfiguration config, TranscoderElement element)
        {
            var parameters = new object[]
            {
                config.Converter(),
                config.Serializer()
            };

            var type = Type.GetType(element.Type, true);

            return(() => (ITypeTranscoder)Activator.CreateInstance(type, parameters));
        }