473,388 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Creating Generic Class from 2 classes

This is a little complicated to explain but I have some web services on a
machine that work great.

The problem is that I have run into a situation where I need to set up my
program to access one or another (could also be 3) different web servers to
use these Web Services. The Web Services are identical on all the machines.
I tried just changing the URL of the Web Services and cannot make it work.
I then decided to create 2 identical web services (one for each machine) and
then use a generic type to use in my code.

The 2 web Servers are Earth and Saturn.

I originally had a Web Service called RemoteUserService, which has a method
fetchRemoteUserInfo.

To make this work I created 2 web services and called them RemoteUserEarth
and RemoteUserSaturn. Both Services are identical except for the URL they
point to and their Namespaces (ClassLibrary4.RemoteUserEarth and
ClassLibrary4.RemoteUserEarth).

I then tried all combinations of defines to make this work and kept coming
up with compiler errors - mainly "Cannot Implicitly assign" errors.

I came closest with:

ClassLibrary4.RemoteUserEarth.RemoteUserServiceSer vice
remoteUserServiceEarth = new
ClassLibrary4.RemoteUserEarth.RemoteUserServiceSer vice();

ClassLibrary4.RemoteUserSaturn.RemoteUserServiceSe rvice
remoteUserServiceSaturn = new
ClassLibrary4.RemoteUserSaturn.RemoteUserServiceSe rvice();

object remoteUserService;

remoteUserService =
(ClassLibrary4.RemoteUserSaturn.RemoteUserServiceS ervice)remoteUserServiceTfs;

This compiles fine, but I can't use the remoteUserService in my code as it
is an object.

ruDataBean = remoteUserService.fetchRemoteUserInfo(
userID,
"swpays",
"10.0.0.25",
"C", //Client (employer)
sessionID);

This gives me an error "'object' does not contain a definition for
'fetchRemoteUserInfo'".

What I am trying to do is get remoteUserService be the generic class that I
can using throughout my code. I don't want to create multiple instances of
the same code when the only difference is the machine I point to. If I then
have to set up a 3rd machine, I would have recreate all my code again for
the 3rd machine. I would much rather just set up another variable, such as
remoteUserServiceMars which I just assign to remoteUserService when I point
to that machine.

Can this be done?

Thanks,

Tom

Apr 4 '06 #1
0 817

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jim Newton | last post by:
hi all, i'm relatively new to python. I find it a pretty interesting language but also somewhat limiting compared to lisp. I notice that the language does provide a few lispy type nicities, but...
16
by: tshad | last post by:
This is a little complicated to explain but I have some web services on a machine that work great. The problem is that I have run into a situation where I need to set up my program to access one...
25
by: Lars | last post by:
Hi, I have a base class holding a generic list that needs to be accessed by both the base class and its subclasses. What is the best solution to this? I am fairly new to generics, but I am...
3
by: Tigger | last post by:
I have an object which could be compared to a DataTable/List which I am trying to genericify. I've spent about a day so far in refactoring and in the process gone through some hoops and hit some...
3
by: Simon Hart | last post by:
Hi, I am trying to implement some functionality as seen in MS CRM 3.0 whereby a basic Xml is deserialized into an object which contains properties. What I want to do from here is; cast the basic...
26
by: nyathancha | last post by:
Hi, How Do I create an instance of a derived class from an instance of a base class, essentially wrapping up an existing base class with some additional functionality. The reason I need this is...
5
by: Torben Laursen | last post by:
I am writing a COM in C# using visual studio 2005 and VSTO. Inside the code I use some support classes that are generic but they are not used in the inferface of the COM. However I still get a...
2
by: Polaris431 | last post by:
I need to implement a tree structure that can accept various types of classes or structs. When the tree is created, all of its nodes are based on a single type and not a mixture of types. ...
10
by: phancey | last post by:
I'm quite new to generics. I have 2 generic classes: MyClass<Tand MyOtherClass<T>. MyClass<Thas 2 public Add methods Add(MyOtherClass<T>); Add(MyOtherClass<Wrapper<T>>); (Wrapper<Tis another...
1
by: Charles Law | last post by:
I have a base class MyBaseClass, and several classes that inherit from it: MyClass1, MyClass2, etc. The base class implements IEnumerable(Of IMyBaseClassRow). The base class has a DataTable...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.