publicabstractbool PerformOperator(int a, int b); // Or what ever type a and b need to be
publicclass EqualsFilter : FilterBase
publicbool PerformOperator(int a, int b);
return (a == b);
// Create other classes as necessary.
The above is an example of the strategy pattern.
Each item in the combo box is assosiated with a specific instance of the Filter class (or rather one of its derived varients). Because the FilterBase class cotains the methods needed, that is all you ever need to reference. Once set up the rest of the code does not need to know anything about each of the specialised classes.
I have a class, let us say Customer which has a set of properties. I am using this class that is in a common dll in two different services (say Service1,Service2). Now i have a windows application (say WinApplication1)where i am adding reference to both the Services. So i have access to the Customer object in two differenct ways.
In my application i want to get a customer object from this service and pass it into the other service as an input. But i am getting casting problem.
It says "Cannot implicitly convert type WinApplication1.Service1.Customer to WinApplication1.Service2.Customer"
Please let me know if there is a easy way to do this conversion?
You appear to have defined Customer twice. Once in each service. You should place Customer in its own Class Library project and then reference it from any other project that needs it. Assuming Customer is identical in each of the existing projects this should work fairly easily. However, if Customer in each of the existing projects, is the same in name only then you have a lot of work ahead of you to redesign your application.
The Customer Object is in a separate class library project only. I have referenced it in both the services. Now my win application is consuming both the service. Now i am getting the Customer object as an output of Service1 that has a datatype of Service1.Customer and when i try to pass it as an input to one of the methods in Service two that expects Service2.Customer, I am not able to do it.
The contents of the object Customer are the same.
Now what to do?
I'm confused. You now appear to have 3 definitions for a Customer object. You should only have one throughout your entire solution.
You should be using only the customer object in the class library. You need to remove the definitions of Customer in the Services and use the Customer class in the class library instead. You can add the class library as a reference to each project that needs it. You can do that by right-clicking the project and selecting "Add Reference..." and going to the projects tab and choosing the class library project that contains the Customer class.
Hey i am doing as you are telling only. There are no multiple copies of the class. It is there in the common project(separate class library). But when you use the class by adding reference to the services then the wsdl of each and every service since it is in a different namespace will consider the same class as two different class files.