Esempio n. 1
0
 public void Setup()
 {
     _argument = new object[] { 1, "abc", DateTime.Now, new List <decimal> {
                                    1m, 11.7m
                                } };
     _binaryFormatterArgumentSerializer = new BinaryFormatterArgumentSerializer();
 }
Esempio n. 2
0
 private KeyCreator(
     IArgumentSerializer argumentSerializer,
     IMemberInfoSerializer memberInfoSerializer,
     IHashAlgorithm hashAlgorithm,
     IStringEncoder stringEncoder)
 {
     _argumentSerializer   = argumentSerializer;
     _hashAlgorithm        = hashAlgorithm;
     _stringEncoder        = stringEncoder;
     _memberInfoSerializer = memberInfoSerializer;
 }
Esempio n. 3
0
        /// <summary>
        /// Converts the argument by serializing it.
        /// </summary>
        /// <remarks>
        /// This method converts the <paramref name="argument"/> by serializing it.
        /// But keep in mind, serialization takes place only for complex data types.
        /// The <paramref name="argument"/> is only formatted if it is recognized as
        /// system type.
        /// </remarks>
        /// <param name="token">
        /// The token to be processed.
        /// </param>
        /// <param name="options">
        /// The options to be used.
        /// </param>
        /// <param name="argument">
        /// The argument to be formatted.
        /// </param>
        /// <returns>
        /// The argument in its formatted representation.
        /// </returns>
        private static String ToSpreadingValue(this BaseToken token, Options options, Object argument)
        {
            if (argument.IsSystemType())
            {
                return(token.ToFormattedValue(options, argument));
            }
            else
            {
                IArgumentSerializer serializer = options.Serializer ?? TemplateWeaver.FallbackSerializer;

                return(serializer.Serialize(options.Provider, token.Format, token.Lining, argument) ?? String.Empty);
            }
        }
 /// <summary>
 /// Formats the list of <paramref name="arguments"/> into the <paramref name="format"/> string using
 /// given format <paramref name="provider"/> as well as given argument <paramref name="serializer"/>.
 /// </summary>
 /// <remarks>
 /// This method formats the list of <paramref name="arguments"/> into the <paramref name="format"/> string
 /// using given format <paramref name="provider"/> as well as given argument <paramref name="serializer"/>.
 /// </remarks>
 /// <param name="provider">
 /// An instance of a <see cref="IFormatProvider"/> derived class used the to perform culture-specific
 /// formatting.
 /// </param>
 /// <param name="serializer">
 /// An instance of a <see cref="IArgumentSerializer"/> derived class used the to perform any kind
 /// of serialization for custom types.
 /// </param>
 /// <param name="relations">
 /// When this method returns, this parameter contains a list of Label-Value relations consisting
 /// of the labels taken from <paramref name="format"/> and the <paramref name="arguments"/> as
 /// their values.
 /// </param>
 /// <param name="format">
 /// A string containing formatting instructions, either for index-based formatting, like
 /// <c>"{0}, {1}, ..."</c>, or for template-based formatting, like <c>"{name1}, {name2}, ..."</c>).
 /// </param>
 /// <param name="arguments">
 /// The optional list of arguments to be used.
 /// </param>
 /// <returns>
 /// A copy of <paramref name="format"/> with the format elements replaced by the string representation
 /// of the corresponding objects in <paramref name="arguments"/>.
 /// </returns>
 /// <seealso cref="Template.Format(String, Object[])"/>
 /// <seealso cref="Template.Format(IFormatProvider, String, Object[])"/>
 /// <seealso cref="Template.Format(IArgumentSerializer, String, Object[])"/>
 /// <seealso cref="Template.Format(Options, String, Object[])"/>
 public static String Format(IFormatProvider provider, IArgumentSerializer serializer, out IArgumentRelations relations, String format, params Object[] arguments)
 {
     return(Template.Format(false, Options.Create(provider, serializer), out relations, format, arguments));
 }
 /// <summary>
 /// Formats the list of <paramref name="arguments"/> into the <paramref name="format"/> string
 /// using given argument <paramref name="serializer"/>.
 /// </summary>
 /// <remarks>
 /// This method formats the list of <paramref name="arguments"/> into the <paramref name="format"/>
 /// string using given argument <paramref name="serializer"/>.
 /// </remarks>
 /// <param name="serializer">
 /// An instance of a <see cref="IArgumentSerializer"/> derived class used the to perform any kind
 /// of serialization for custom types.
 /// </param>
 /// <param name="format">
 /// A string containing formatting instructions, either for index-based formatting, like
 /// <c>"{0}, {1}, ..."</c>, or for template-based formatting, like <c>"{name1}, {name2}, ..."</c>).
 /// </param>
 /// <param name="arguments">
 /// The optional list of arguments to be used.
 /// </param>
 /// <returns>
 /// A copy of <paramref name="format"/> with the format elements replaced by the string representation
 /// of the corresponding objects in <paramref name="arguments"/>.
 /// </returns>
 /// <seealso cref="Template.Format(String, Object[])"/>
 /// <seealso cref="Template.Format(IFormatProvider, String, Object[])"/>
 /// <seealso cref="Template.Format(IFormatProvider, IArgumentSerializer, String, Object[])"/>
 /// <seealso cref="Template.Format(Options, String, Object[])"/>
 public static String Format(IArgumentSerializer serializer, String format, params Object[] arguments)
 {
     return(Template.Format(true, Options.Create(null, serializer), out _, format, arguments));
 }