有没有一种方法可以根据字符串变量(不是字符串类型)的值来创建特定类型的对象?

I'm trying to instance multiple objects of diverse types based on what you set on the config file.

Also, I'm trying to avoid to use the 'switch' statement with every Type of object that you can instance.

My original idea was use sort type of reflection, to create a object with a Type obtained from a config value.

For example: These is a YAML Config example

workers:
  - type: "Type1"
    parameters:
      param_0: "test"
      param_1: 1000
  - type: "Type2"
    parameters:
      param_0: "test"
      param_1: 1000

When these settings are analyzed; at run-time, the program must instance a "Type1" object with the "Parameters"; and then another instance of a "Type2" object with its "Parameters".

Please let me know if you need more information about it.

PD: Sorry for my bad English.