473,473 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Generics Objects

Hi all,

I created a Class defined as:

public class GenericDataAccess<T: DataAccessObject<Twhere T :
DBObject

This is my base class. I reuse it in every project. Now, in a
particular project I have another class:

public class DataAccess<T>: GenericDataAccess<Twhere T:DBObject

This last class have methods as:

public static List<TgetAll()
public static T getOne()
....

I also have one method called:

public static bool IsLogin(string userName, string password)

I would like to make this method accesible just for one class, that is
called User and inherits from DBObject.
But I do not want it to be accesible for the rest of the classes that
inherit from DBObject (i.e. Role, Apartment...)

Any idea of how can I implement my idea?

Thanks in advance

Apr 12 '07 #1
3 1134
On 12 Apr, 13:42, "VicToro" <vicp...@googlemail.comwrote:
Hi all,

I created a Class defined as:

public class GenericDataAccess<T: DataAccessObject<Twhere T :
DBObject

This is my base class. I reuse it in every project. Now, in a
particular project I have another class:

public class DataAccess<T>: GenericDataAccess<Twhere T:DBObject

This last class have methods as:

public static List<TgetAll()
public static T getOne()
...

I also have one method called:

public static bool IsLogin(string userName, string password)

I would like to make this method accesible just for one class, that is
called User and inherits from DBObject.
But I do not want it to be accesible for the rest of the classes that
inherit from DBObject (i.e. Role, Apartment...)

Any idea of how can I implement my idea?
Hello Vic,
your question raises the doubt you are correctly modeling your
objects.

If a derived class does not need a parental field or property then you
are *probably* using wrongly the concept of inheritance.

It makes sense that D inherits from P only if D "is a" P.

When one needs etherogeneous objects to share properties I find
convenient to use interfaces.

Anyway I'd like to hear others' opinions about that.

-Pam
>
Thanks in advance

Apr 12 '07 #2
If you only want the method to be accessible to one derived class, define it
in the derived class.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"VicToro" <vi*****@googlemail.comwrote in message
news:11**********************@e65g2000hsc.googlegr oups.com...
Hi all,

I created a Class defined as:

public class GenericDataAccess<T: DataAccessObject<Twhere T :
DBObject

This is my base class. I reuse it in every project. Now, in a
particular project I have another class:

public class DataAccess<T>: GenericDataAccess<Twhere T:DBObject

This last class have methods as:

public static List<TgetAll()
public static T getOne()
...

I also have one method called:

public static bool IsLogin(string userName, string password)

I would like to make this method accesible just for one class, that is
called User and inherits from DBObject.
But I do not want it to be accesible for the rest of the classes that
inherit from DBObject (i.e. Role, Apartment...)

Any idea of how can I implement my idea?

Thanks in advance

Apr 12 '07 #3

"VicToro" <vi*****@googlemail.comwrote in message
news:11**********************@e65g2000hsc.googlegr oups.com...
Hi all,

I created a Class defined as:

public class GenericDataAccess<T: DataAccessObject<Twhere T :
DBObject

This is my base class. I reuse it in every project. Now, in a
particular project I have another class:

public class DataAccess<T>: GenericDataAccess<Twhere T:DBObject

This last class have methods as:

public static List<TgetAll()
public static T getOne()
...

I also have one method called:

public static bool IsLogin(string userName, string password)

I would like to make this method accesible just for one class, that is
called User and inherits from DBObject.
But I do not want it to be accesible for the rest of the classes that
inherit from DBObject (i.e. Role, Apartment...)

Any idea of how can I implement my idea?

public class UserDataAccess : DataAccess<User>
{
public static bool IsLogin(string userName, string password) { ... }
}
>
Thanks in advance

Apr 12 '07 #4

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

Similar topics

17
by: Andreas Huber | last post by:
What follows is a discussion of my experience with .NET generics & the ..NET framework (as implemented in the Visual Studio 2005 Beta 1), which leads to questions as to why certain things are the...
12
by: Michael S | last post by:
Why do people spend so much time writing complex generic types? for fun? to learn? for use? I think of generics like I do about operator overloading. Great to have as a language-feature, as...
1
by: uttara | last post by:
I have a generic collection which I am using in classes to store a collection of embedded objects. Class Employee: IEntity { Private string mName; Private int mEmployeeID; …. Private...
4
by: Chuck Cobb | last post by:
I have a question regarding generics: Suppose I want to create some generic collection classes: Collection<Cats> c; Collection<Dogs> d; and both Cats and Dogs are inherited from a base class...
1
by: Peter Kirk | last post by:
Hi I have never used generics before, and I was wondering if the following sort of use was acceptable/normal for a method: public IList<IPerson> GetPersons() { IList<IPerson> personList =...
6
by: nick_nw | last post by:
Hi, What significant advantages do generics give me over passing objects around as 'object' and casting when needed? I was asked this recently and started off by saying, "well of course...
14
by: cwineman | last post by:
Hello, I'm hoping to do something using Generics, but I'm not sure it's possible. Let's say I want to have a bunch of business objects and a data access class cooresponding to each business...
11
by: Bryan Kyle | last post by:
Hi All, I'm fairly new to C# and Generics and I'm wondering if anyone has some suggestions for me. I'm trying to implement a simple DAO framework using generics to keep my code as clean as I...
3
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I have some problems with Crystal Reports (Version 10.2, Runtime 2.0). In Section3 I have added a OLE Object (Bitmap). Now when I open the report in my code I would like to set this...
3
by: Anders Borum | last post by:
Hello, I've worked on an API for quite some time and have (on several occasions) tried to introduce generics at the core abstract level of business objects (especially a hierarchical node). The...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.