Esempio n. 1
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);
            }
        }
Esempio n. 2
0
        public string CreateKey(MemberInfo memberInfo, object[] arguments)
        {
            var serializedArguments  = _argumentSerializer.Serialize(arguments);
            var serializedMemberInfo = _memberInfoSerializer.Serialize(memberInfo);

            var serialized = new byte[serializedArguments.Length + serializedMemberInfo.Length];

            serializedArguments.CopyTo(serialized, 0);
            serializedMemberInfo.CopyTo(serialized, serializedArguments.Length);

            var hashed = _hashAlgorithm.CreateHash(serialized);
            var key    = _stringEncoder.BytesToString(hashed);

            return(key);
        }
Esempio n. 3
0
 public byte[] BinaryFormatterArgumentSerializer() => _binaryFormatterArgumentSerializer.Serialize(_argument);