B-Abbasi
B-Abbasi

Reputation: 823

Modify behaviour of a function in a class in c#

We have a framework built for development purpose in our company. In a certain class there is a function which is used to load some special type of files. Function is implemented such that if we select one file to load it will load all other files of that format in the directory too. For our company usually this behavoiur is required, so the function is great and up to the task.
I am making a project where I need only the selected file to be loaded which means I need to alter the implementation of that function. I have tried to inherit the class and then over-ride that specific function but it didn't work so I used ILSpy to inspect the framework and found that the class has a private default constructor.
As it is not possible to inherit a class that has only private constructor so it seems to me that I am totally out of options.
Does anyone know the solution to this issue? Thanks

Upvotes: 0

Views: 68

Answers (2)

CodeCaster
CodeCaster

Reputation: 151730

It really sounds like that method could use another overload, specifying bool loadRelatedFiles = true. Like @Clemens says, consult the original author rather than going haywire using reflection.

Upvotes: 0

Clemens Vasters
Clemens Vasters

Reputation: 2686

If that class is built inside your company, rather than doing a hack (which this would require), I'd find the owner and ask for a change.

Upvotes: 2

Related Questions