473,396 Members | 1,853 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,396 software developers and data experts.

Problem with CustomTyped casting and type checking

I created several classes that supports custom typing as following:

Public Class DataManager(Of CustomType As {DataObject, New})

Public Class LockableDataManager(Of CustomType As {LockableDataObject,
New})
Inherits DataManager(Of CustomType)

Public NotInheritable Class BusinessManager
Inherits LockableDataManager(Of Business)

The problem i'm having is relative to CTYPE. If i try to verify that an
object passed to a function is of type LockableDataManager(Of
LockableDataObject) it never seems to resolve... If you follow the
hierarchy, a BusinessManager is a LockableDataManager(Of Business As
LockdableDataObject) and everything compiles fine but the following
line always returns false on the TYPEOF in the first part, the second
part works well.

If TypeOf pManager Is gumain.LockableDataManager(Of
gumain.LockableDataObject) AndAlso TypeOf Editor.EditedObject Is
gumain.LockableDataObject Then

(The Andalso Editor.EditedObject Is gumain.LockableDataObject resolves
to TRUE it is not the problem therefore)

Can you guys tell me what i can do to fix this and actually explain to
me what is wrong?

Thanks

Aug 11 '06 #1
1 878
I think i have found a part of my solution. It seems for a reason i
can't understand that CustomTyping a class is a valid way to work but
the CustomType is static, meaning it is that or nothing else. You
cannot use anything that is not of that type even if it derives from
it.

There fore to make my code work, i'd need to remove the CustomType from
the class definition which will obviously not happen since i'd need to
make major changes to most of my program.

To prove what i am saying here is a simply test: I changed my
declaration of the containing variable called pManager from the
previous code from :

Protected pManager As LockableDataManager(Of LockableDataObject)
To
Protected pManager As LockableDataManager(Of Business)

And now the calls resolve correctly. Since Business derives from
LockdableDataObject we can only assume one thing, CustomTyping doesn't
take into effect the inheritance of a class even when casting or when
checking the type using typeof...

Anyone has a simple anwser to help me?

Aug 11 '06 #2

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

Similar topics

4
by: Leslaw Bieniasz | last post by:
Cracow, 20.09.2004 Hello, I need to implement a library containing a hierarchy of classes together with some binary operations on objects. To fix attention, let me assume that it is a...
3
by: DJ.precario | last post by:
Hi, I have a vector (myVector) of BaseClass objects. I store in it a DerivedClass object (where DerivedClass inherits from BaseClass). Later I want to get the last element in the vector and...
17
by: Jon Slaughter | last post by:
I'm having a little trouble understanding what the slicing problem is. In B.S.'s C++ PL3rdEd he says "Becayse the Employee copy functions do not know anything about Managers, only the Employee...
231
by: Brian Blais | last post by:
Hello, I saw on a couple of recent posts people saying that casting the return value of malloc is bad, like: d=(double *) malloc(50*sizeof(double)); why is this bad? I had always thought...
7
by: yufufi | last post by:
lets say we have a 'shape' class which doesn't implement IComparable interface.. compiler doesn't give you error for the lines below.. shape b= new shape(); IComparable h; h=(IComparable)b;...
7
by: Jim Bancroft | last post by:
Hi everyone, A basic one here, I think. I haven't found the pattern yet, but sometimes when I cast a variable to another type using the "C" style cast operator the compiler refuses to play...
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
39
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1)...
1
by: =?Utf-8?B?QkpT?= | last post by:
I have written a Generic method that takes an object, a type, T, and returns a System.Nullable (Of T) depending on whether or not the object IsDBNull. It was working fine until I tried to pass a...
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...
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.