I think I oversnipped my code. "parameters" is an array of ParameterInfo
objects. .ParameterType returns a System.Type. Here's the code:
foreach(ConstructorInfo ctor in
settingType.GetConstructors())
{
ParameterInfo[] parameters =
ctor.GetParameters();
if(parameters.Length == 1)
{
if(parameters[0].ParameterType
is System.Xml.XmlNode)
{
object[] theParams =
{settingNode};
try
{
theSetting =
(IGroupOneSetting)ctor.Invoke(theParams);
settingIsCreated
= true;
}
catch
{
settingIsCreated
= false;
}
}
}
}
Obviously, "is" doesn't work here. So, I guess the question now boils
down to--If I have an object of type System.Type, how do I determine
what type it represents? Currently, I'm using the following hack:
// HACK - Jekke 20041027 - Huge hack to get object type.
if(parameters[0].ParameterType.ToString() = "System.Xml.XmlNode")
But, I know that can't be the right way to do it.
TIA.
--Jekke
-----Original Message-----
From: Unmoderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Srihari
Angaluri
Sent: Wednesday, October 27, 2004 3:43 PM
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] Depending on what your definition of is
is...
My understanding is, "is" actually stands for "is an instance of
type..".
i.e. it basically compares the "type" of the object on the LHS with the
actual type on the RHS. Going by that definition, you are actually
comparing the type of your instance to the type XmlNode, rather than
comparing the actual instance of XmlNode. You should instead try:
if (parameters[0] is System.Xml.XmlNode)
{
...
}
On Wed, 27 Oct 2004, Jekke Bladt wrote:
> I think I'm missing some subtlety regarding the "is" keyword here.
>
> Here's what the helpfile says about it:
>
> An is expression evaluates to true if both of the following conditions
> are met:
>
> expression is not null.
> expression can be cast to type. That is, a cast expression of the form
> (type)(expression) will complete without throwing an exception. For
more
> information, see 7.6.6 Cast expressions.
>
> Where I'm getting strangeness is the line:
> if(parameters[0].ParameterType is System.Xml.XmlNode)
>
> Even when the parameter type *is* System.Xml.XmlNode, it evaluates to
> false.
>
> What am I missing?
>
> TIA
>
> --Jekke
>
> ===================================
> This list is hosted by DevelopMentor(r) http://www.develop.com
> Some .NET courses you may be interested in:
>
> Essential .NET: building applications and components with C#
> November 29 - December 3, in Los Angeles
> http://www.develop.com/courses/edotnet
>
> View archives and manage your subscription(s) at
http://discuss.develop.com
>
===================================
This list is hosted by DevelopMentor(r) http://www.develop.com
Some .NET courses you may be interested in:
Essential .NET: building applications and components with C#
November 29 - December 3, in Los Angeles
http://www.develop.com/courses/edotnet
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentor� http://www.develop.com
Some .NET courses you may be interested in:
Essential .NET: building applications and components with C#
November 29 - December 3, in Los Angeles
http://www.develop.com/courses/edotnet
View archives and manage your subscription(s) at http://discuss.develop.com