
BotFactory, as the name suggests, is a factory for robots. The vast majority of objects we use in the real world are produced in specially equipped locations known as factories, manufacturing plants, and so on. Similarly, in OsEngine, the creation of trading robot instances is handled by a specially designated object.
It is in this class that OsEngine requests the list of available robots within the system. It is also where instances of robots are created.
The class code can be found in the file BotFactory.cs in the directory.
In the project, if you open OsEngine, this class is located here:

The BotFactory class encapsulates all the logic for creating robots in one place, but there are three ways to enable the factory to create instances of robots. Currently, however, only ONE method is correct: through the use of the BotAttribute class attribute.
Let's consider all members of the BotFactory class. The class itself:

BotsWithAttribute – a private static read-only field. It contains a dictionary where the key is the robot type name, and the value is a reference to the type object of the robot class.
GetNamesStrategy – a public static method. Returns a list of robot names that are created in the classical way and by using the class attribute.
GetStrategyForName – a public static method. It encapsulates the logic of creating robots in the classical way and using the class attribute. It accepts the following parameters:
nameClass - the name of the class whose instance needs to be created;
name - a unique name for the robot instance;
startProgram - the type of program that initiated the method request;
isScript - a flag. Indicates whether to load the robot code as an external script;
GetTypesWithBotAttribute – a private static method. Initializes the BotsWithAttribute field.
GetScriptsNamesStrategy – a public static method. Returns a list of robot names that are created by loading from files as scripts.
GetFullNamesFromFolder – a private static method. Returns a list of strings indicating the paths to the script code.
CreateScriptStrategyByName – a public static method. It encapsulates the logic of creating robot instances from script files. It accepts the following parameters:
nameClass - the name of the class whose instance needs to be created;
name - a unique name for the robot instance;
startProgram - the type of program that initiated the method request;
Serialize – a private static method. Generates and then compiles the script code from the file.
GetDllsPathFromFolder – a private static method. Returns the path to the dll libraries necessary for compiling the script code.
ReadFile – a private static method. Reads the code from a text file at the specified path.
GetNamesStrategyWithParametersSync – a public static method. Used by the optimizer, synchronizes the process of obtaining a list of class names for robots that have optimizable parameters.
NeedToReload – a public static boolean field. A flag indicating the need to reload the list of robot class names.
LoadBotsNames – a private static method. Loads the list of robot names that have optimizable parameters into a variable.
SaveBotsNames – a private static method. Saves the list of robot names that have optimizable parameters into storage.
LoadNamesWithParam – a private static method. Loads the list of robot class names that have optimizable parameters into a variable.
LoadNamesWithParamEndEvent – a public static event. Notifies subscribers of the readiness of the bot list with parameters.
Good luck with your algorithms!
If you have any difficulties or questions, please write to the support chat. Link