I need to add many public folders from the configuration file. the names are very long, but it all ends with the words "Name", "Domain", "Username" and "Password".
Example:
AddSharedFolder(
myConfigurationHandler.MyConfiguration.MyService.RSController.repositoryName,
myConfigurationHandler.MyConfiguration.MyService.RSController.repositoryDomain,
myConfigurationHandler.MyConfiguration.MyService.RSController.repositoryUsername,
myConfigurationHandler.MyConfiguration.MyService.RSController.repositoryPassword);
My idea was to call him
AddSharedFolder(
"myConfigurationHandler.MyConfiguration.MyService.RSController.repository");
Then you have the overloaded AddSharedFolders method:
private static void AddSharedFolder(string prefix)
{
AddSharedFolder(prefix + "Name", prefix + "Domain", prefix + "Username", prefix + "Password");
}
Obviously, the latter method is incorrect. But how to convert a string to a variable name? Or is it really a stupid programming practice?
source
share