tags:

views:

74

answers:

1

I have a bunch of classes of the following format, located in the various namespaces. Instances of these classes are serialized and de-serialized objects across the network.

public class Foo:INetSerializable
{

    public void ReadObjectData(Streamer stream)
    {

    }

    public void WriteObjectData(Streamer stream)
    {


   }
}

In a different namespace, I have a Dispatcher class that uses some criteria to serialize/deserialize these instances.

However, I don't want users to see these methods in my documentation. I cannot make these guys internal because then Dispatcher wouldn't be able to access them.

I use Visual Studio 2005, so I cannot take advantage of C# 3.0.

How can I do this?


Another Error:

How do I deal with a class that inherits from Foo and overrides the Read and WriteObjectData for example, the following is giving me this error: type does not implement interface INetSerializable

public class Bar:Foo
    {

        public void ReadObjectData(Streamer stream)
        {

        }

        public void WriteObjectData(Streamer stream)
        {


       }
    }
+1  A: 

You can use explicit interface implementation. I believe the syntax would be

void INetSerializable.ReadObjectData(Streamer stream)

Note that it doesn't say "public", so it's not public. It can only be accessed through the interface.

John Saunders
If someone instantiates the class though through the interface, i.e. INetSerializable obj = new Foo(); these would then be visible to the user wouldn't they?
REA_ANDREW
Yes, they would - but I suspect most people won't do that. It at least gets them out of the way for normal use. You can't actually stop them from getting called though.
Jon Skeet
Right. He said he didn't want users to see the methods, but he wanted his Dispatcher to be able to call them.
John Saunders
I guess, explicit interface implementation solves the problem. Plus, a client cannot use INetSerializable as I don't expose it in the API. ..thx again