Passing enums across boundaries

  • Thread starter Thread starter guy
  • Start date Start date
G

guy

VS2005

I have a solution containing (amongst others) a Business layer project and a
DataAccess layer project.

Within these two projects I have a Class DoStuff , the business layer
doStuff makes calls to the DataAccess layer DoStuff. some of these calls
involve passing an enum as a parameter.

This enum is meaningless outside these two classes. The only way I can see
to make it visible to these two classes but not any other classes is to
define it in each class and make it Private, casting it where needed. This
however is not very clean.

Anyone have another suggestion?

Guy
 
Why does it have to be private?

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP
 
Well it could be Protected I suppose, but what I need to do is to make theis
enum visible to two and only two classes, which are in different projects.

I dont want other classes to be able to see this enum as it is similar to
another enum that has wide visibility. This could cause confusion to other
developers.

Guy
 
guy said:
Well it could be Protected I suppose, but what I need to do is to make
theis
enum visible to two and only two classes, which are in different projects.

I dont want other classes to be able to see this enum as it is similar to
another enum that has wide visibility. This could cause confusion to other
developers.

Guy

Unless your two classes are somehow related via inheritance, I doubt
"Protected" will do it.

From VS docs:
The protected keyword is a member access modifier. A protected member is
accessible from within the class in which it is declared, and from within
any class derived from the class that declared this member.

A protected member of a base class is accessible in a derived class only if
the access takes place through the derived class type.
 
Well, you have a couple of choices:

1. Rename the enum and make it public.
2. Don't use an enum. Use integers instead.
3. Cast to and from integers.

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP
 
Well, you have a couple of choices:

1. Rename the enum and make it public.
2. Don't use an enum. Use integers instead.
3. Cast to and from integers.

Would the visitor pattern be of use here?

regards
A.G.
 
Back
Top