Question

I have some functions here that for example are defined as

private int WriteLogikParameterTyp(FileStream filestream)

which i can not change. I want them to write into a MemoryStream Object. Is this possible?

Was it helpful?

Solution

No.

FileStream is a concrete implementation.

But it's a private method so should be easy enough to change since you can find all internal uses? Suggest replacing method signature with Stream rather than FileStream.

Well... unless you create a tempory file, write to it then read it into memory.

OTHER TIPS

Since you can't change the function signature to accept a more generic type.. I'd suggest writing out to a temporary file and then reading the contents into a MemoryStream instance.

No.

If you do not have access to them, you could use reflector to find out how they work and implement your own version for a MemoryStream. Whether this is legal is another matter...

No. FileStream doesn't expose a constructor that can be called so you can't inherit from it in order to emulate it.

Suggestion;

Rename the method like this

private int WriteLogikParameterTyp_Ex(Stream stream);

Then recreate the original signature like;

private int WriteLogikParameterTyp(FileStream filestream)
{
     return WriteLogikParameterTyp_Ex(filestream);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top