Hi
I am using a DynamicProxy (class that inherits from RealProxy). I don't know the type of my Transparant Proxy at compile time. Is there a possibility to have a dynamic casting
object[] correctParams = new object[x]
for(int i...
Type t = Type.GetType(ti B.GetTypeName() )
DynamicProxy proxy = new DynamicProxy(t, orderedParams[i], tiA)
correctParams[i] = /*TODO: CAST into type t*/ proxy.GetTransp arentProxy()
I would like to cast the result of proxy.GetTransp arentProxy() into the type t. Is it possible
Thanks a lo
Valéry Bezençon 4 4963
=?Utf-8?B?VmFs?= <an*******@disc ussions.microso ft.com> wrote: I am using a DynamicProxy (class that inherits from RealProxy). I don't know the type of my Transparant Proxy at compile time. Is there a possibility to have a dynamic casting?
object[] correctParams = new object[x]; for(int i...) { Type t = Type.GetType(ti B.GetTypeName() ); DynamicProxy proxy = new DynamicProxy(t, orderedParams[i], tiA); correctParams[i] = /*TODO: CAST into type t*/ proxy.GetTransp arentProxy(); }
I would like to cast the result of proxy.GetTransp arentProxy() into the type t. Is it possible?
What difference would it make? correctParams is just an array of object
references - why would you need to cast the reference?
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
----- Jon Skeet [C# MVP] wrote: ----
=?Utf-8?B?VmFs?= <an*******@disc ussions.microso ft.com> wrote I am using a DynamicProxy (class that inherits from RealProxy). I don't know the type of my Transparant Proxy at compile time. Is there a possibility to have a dynamic casting object[] correctParams = new object[x] for(int i...
Type t = Type.GetType(ti B.GetTypeName() ) DynamicProxy proxy = new DynamicProxy(t, orderedParams[i], tiA) correctParams[i] = /*TODO: CAST into type t*/ proxy.GetTransp arentProxy()
I would like to cast the result of proxy.GetTransp arentProxy() into the type t. Is it possible
What difference would it make? correctParams is just an array of object
references - why would you need to cast the reference
I need to use the methods contained in the Type t on the objects of correctParams in the rest of the code. If these object are just object, I will only be able to use the methods of the class object (GetType, GetHashCode, ...
[Please fix your newsreader to wrap text at about 72 columns - your
current long lines make it a pain to reply to you.]
=?Utf-8?B?dmFs?= <an*******@disc ussions.microso ft.com> wrote: What difference would it make? correctParams is just an array of object references - why would you need to cast the reference?
I need to use the methods contained in the Type t on the objects of correctParams in the rest of the code. If these object are just object, I will only be able to use the methods of the class object (GetType, GetHashCode, ...)
But casting where you suggested casting wouldn't do you any good
anyway. Actually, it would check that the cast it valid, but that's
all.
If you don't know the type in advance, you won't be able to use the
methods in your code anyway, will you? If you know that the type will
have certain methods, then build an interface with those methods, make
the type implement those methods, and cast to the interface when you
need to.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
----- Jon Skeet [C# MVP] wrote: ----
[Please fix your newsreader to wrap text at about 72 columns - your
current long lines make it a pain to reply to you.
=?Utf-8?B?dmFs?= <an*******@disc ussions.microso ft.com> wrote What difference would it make? correctParams is just an array of object references - why would you need to cast the reference I need to use the methods contained in the Type t on the objects of correctParams in the rest of the code. If these object are jus object, I will only be able to use the methods of the class object (GetType, GetHashCode, ...
But casting where you suggested casting wouldn't do you any good
anyway. Actually, it would check that the cast it valid, but that's
all
If you don't know the type in advance, you won't be able to use the
methods in your code anyway, will you? If you know that the type will
have certain methods, then build an interface with those methods, make
the type implement those methods, and cast to the interface when you
need to
Yes, you are right, I was a little bit confused. Thanks for your hel
Valéry This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jason Tesser |
last post by:
I work for at a college where I am one of 2 full-time
developers and we are looking to program a new
software package fro the campus. This is a huge
project as it will include everything from
registration to
business office. We are considering useing Java or
Python. I for one don't like Java because I feel the
GUI is clunky. I also think that we could produce
quality programs faster in Python.
|
by: Radde |
last post by:
HI,
Are ther any pitfalls for dynamic cast in type safe downcasting..
|
by: Zac |
last post by:
Alright anyone who has 2c throw it in...
I am working through a custom xml serializer and have come upon a
conundrum, given our class design.
The interface implemented on the base class (base for all business
entities) dictates that the implementing class expose a Dirty property
(for state).
The base class (that actually manages state, once for all inheritors)
|
by: Martin Hart - Memory Soft, S.L. |
last post by:
Hi all:
I still very new to the .NET world and don't know if what I am asking is due
to an over-imaginative imagination or the fact that I have read too many
fiction books!!
Let me show you a very basic scenario:
using System;
|
by: Philipp Schumann |
last post by:
Hi,
I have a need for "dynamic type casting": in other words, in a "MyConvert"
method I get passed an Object "value" and a Type "type" and the method
should attempt to convert value into type.
Of course it first tries to obtain the appropriate TypeConverter. However,
for some types there are no applicable type converters.
Consider a custom class "Dummy" from a linked assembly (in my scenario,
neither the Dummy type nor its assembly...
| |
by: Zark3 |
last post by:
Hi all,
I was wondering if anybody could enlighten me on the possibility of
dynamic casting. Or, well, whether or not I'm actually trying to do
this the right way.
What I have is a base class that several classes inherit from. From
time to time I need to add new inherited types so I want something that
is as versatile as possible, preferably not requiring naming all
subtypes in a switch statement.
|
by: Mike Stevenson |
last post by:
Hi. I'm in the process of re-learning all the C++ I forgot from
college, and I'm starting to get into some virgin (or at least only a
couple times) territory. I have some questions about casting a pointer
from a base class to a derived class. For example:
class Base{
public:
Base() {}
virtual ~Base() {}
void func1(int);
|
by: DaTurk |
last post by:
Hi,
I have three interfaces lets call them parent, child-A, and child-B. I
want to have one variable, that can be either child-A, or child-B at
run time. I just can't seem to figure out how to do it. They both
inherit from parent, and I tried holding a parent variable, and then
casting it down to either of the children, but I can't see either of
the childrens unique methods.
Thanks in advance for the help.
|
by: hlubenow |
last post by:
Hello,
I really like Perl and Python for their flexible lists like @a (Perl) and
a (Python), where you can easily store lots of strings or even a whole
text-file.
Now I'm not a C-professional, just a hobby-programmer trying to teach it
myself. I found C rather difficult without those lists (and corresponding
string-functions).
Slowly getting into C-strings, I thought, what if I take a C-string and
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |