I am working with someone else's code and trying to make some modifications. So what I'm needing to do is take the following:
RemoteFileDP remoteFile = new DPFactory().CreateRemoteFileDP(configData);
And change it so that remoteFile can equal what is in a string variable. To further explain let me give some more of the code:
ConfigDP configData = new ConfigDP();
So the statement above is executed before the remoteFile statement and ConfigDP is has two classes above it (abstract Config and then its base: abstract ConfigBase). DP is also the child of two abstract classes above it (abstract RemoteFile and abstract RemoteFileBase).
From my understanding remoteFile is the result of data extracted from a database query, stored into a list or a Hashtable (sorry just an intern so I'm working through this).
The reason I need remoteFile to accept a string value is because there are MANY methods that utilize the information in remoteFile and I would like to avoid having to create a WHOLE BUNCH of overloaded methods that accept a string value instead of RemoteFileDP remoteFile.
So if I can take a string value like:
string locationDirectory;
which is passed in from another method and then have something similar to the following:
RemoteFileDP remoteFile = locationDirectory;
then all other methods using remoteFile will not have to be overloaded or changed.
Sorry for all the detail but this is my first time posting so I hope I provided enough information. I did look at C# Convert dynamic string to existing Class and C#: Instantiate an object with a runtime-determined type and wrote the following code:
RemoteFilesDP remoteFile = (RemoteFileDP)Activator.CreateInstance(typeof(RemoteFileDP), locationDirectory);
However I keep getting a "MissingMethodException" error that the constructor for RemoteFileDP is not found but I do have the constructor as seen below:
public RemoteFileDP()
{
} //end of RemoteFilePlattsDP constructor
Thank you ahead of time for your assistance!