/// <summary> /// Creates a <see cref="DynamicMethod"/> that will be used as the /// factory method and stores it in the method cache. /// </summary> /// <param name="targetMethod">The constructor that will be used to instantiate the target type.</param> protected virtual void GenerateTargetMethod(TMethod targetMethod) { MethodBase result = null; // HACK: Since the Mono runtime does not yet implement the DynamicMethod class, // we'll actually have to use the constructor itself to construct the target type result = Runtime.IsRunningOnMono ? targetMethod : _builder.CreateMethod(targetMethod); // Save the results lock (_cache) { _cache[targetMethod] = result; } }