Exemplo n.º 1
0
 /// <summary>
 /// Emits the code needed to properly push an object on the stack,
 /// serializing the value if necessary.
 /// </summary>
 /// <param name="typeBuilder">The TypeBuilder for the method being built.</param>
 /// <param name="methodBuilder">The method currently being built.</param>
 /// <param name="invocationContext">The invocation context for this call.</param>
 /// <param name="invocationContexts">A list of invocation contexts that will be appended to.</param>
 /// <param name="invocationContextsField">The static field containing the array of invocation contexts at runtime.</param>
 /// <param name="parameterMapping">The mapping of source parameters to destination parameters.</param>
 /// <param name="serializationProvider">The serialization provider for the current interface.</param>
 /// <param name="serializationProviderField">
 /// The field on the current object that contains the serialization provider at runtime.
 /// This method assume the current object is stored in arg.0.
 /// </param>
 internal static void EmitSerializeValue(
     TypeBuilder typeBuilder,
     MethodBuilder methodBuilder,
     InvocationContext invocationContext,
     List <InvocationContext> invocationContexts,
     FieldBuilder invocationContextsField,
     ParameterMapping parameterMapping,
     TraceSerializationProvider serializationProvider,
     FieldBuilder serializationProviderField,
     List <(string, LambdaExpression)> parameterConverters)
Exemplo n.º 2
0
        /// <summary>
        /// Adds a mapping to the list of mappings
        /// </summary>
        /// <param name="mappings">The list of parameter mappings.</param>
        /// <param name="parameterInfo">The parameter being evaluated.</param>
        /// <param name="parameterName">The name of the parameter.</param>
        /// <param name="alias">The alias to use to output the parameter.</param>
        /// <param name="converter">An optional expression to use to convert the parameter.</param>
        private static void AddMapping(List <ParameterMapping> mappings, ParameterInfo parameterInfo, string parameterName, string alias, LambdaExpression converter)
        {
            // find the mapping that matches the name or create a new mapping
            var mapping = mappings.FirstOrDefault(p => String.Compare(p.Name, parameterName, StringComparison.OrdinalIgnoreCase) == 0);

            if (mapping == null)
            {
                mapping = new ParameterMapping(parameterName);
                mappings.Add(mapping);
            }

            mapping.AddSource(parameterInfo, alias, converter);
        }