/// <summary> /// Emits the instructions that will instantiate the current implementation. /// </summary> /// <param name="dependency">The dependency that describes the service to be instantiated.</param> /// <param name="serviceMap">The service map that contains the list of dependencies in the application.</param> /// <param name="targetMethod">The target method.</param> public void Emit(IDependency dependency, IDictionary <IDependency, IImplementation> serviceMap, MethodDefinition targetMethod) { _emitter.EmitService(targetMethod, dependency, _implementation, serviceMap); var il = targetMethod.GetILGenerator(); var module = targetMethod.Module; var serviceType = module.Import(dependency.ServiceType); if (serviceType.IsValueType) { return; } il.Emit(OpCodes.Castclass, serviceType); }