Put the custom configuration code in its own DLL & have (1) & (2) both reference it. Then modify (2) so it uses the custom configuration code.
How to solve this cycle dependency in c# project?
-
14-10-2022 - |
Question
I am modifying a project (1) (windows service). I was given a utility project(2) and I am using this is my project. I dont know why but this (2) has an initialization using ConfigurationManager.AppSettings[]
I use a custom config reader in my project as I wanted my own XML structure. The utility has no options to initialize using contructors or methods.
I did not want to change this utility much so I just changed this initialization using AppSettings to the config class in (1) (by creating a dependency to (1) from (2)). I know this is not the way to go about it. If I clean my solution it would be mess.
I could think of some ways. But not sure which will be the correct approach?
- Have another config file
- Continue with cyclic dependency
- Pass on parameters and change the utility
- (there are too many parameters) should I pass all values as string and write logic in utility to convert them back?
Project 1
using utility;
ns pr1;
CustomConfigReader{ }
Project 2
using pr1;
ns utility;
UtilityClass{
//Initialization of a lot variables
pr1.CustomConfigReader .......
}
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow