Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Reflection with Generic Collection types

Reply
 
Old 02-03-2009   #1 (permalink)
Fernando Arámburu


 
 

Reflection with Generic Collection types

hi everybody,

I´m working on a very strange dotnet Reflection component and i´m having
some troubles with reflection on generic types. To talk more concretely I
will gvie you some examples of what i´m looking at.

The method where I´m having some troubles needs to do get the generic
collection type from a generic collection variable. Examples (Please forget
about namespaces, í´m not writing them just to be more clear)

I have My Method
should return
List<int> List< >
type instance
Dictionary<string, object> Dictionary<> type
instance

By now I know how to get the parameter types (like int in the first
example and string and object in the second one) and how to get something
like List'1<int> or Dictionary'2<string, object> and I know I can parse the
type name as a string and then everything is fixed but I think there is some
whay to get what i´m looking at by using Reflection library. Can someone
give me a hand?

Thanks in advance.

Fernando




My System SpecsSystem Spec
Old 02-03-2009   #2 (permalink)
Cor Ligthert[MVP]


 
 

Re: Reflection with Generic Collection types

Fernando,

Are you sure you cannot simple set Option Strict to Off to get the same
results without reflection?

Cor

"Fernando Arámburu" <fernando@xxxxxx-group.com> wrote in message
news:u1J7ZKghJHA.1184@xxxxxx
Quote:

> hi everybody,
>
> I´m working on a very strange dotnet Reflection component and i´m
> having
> some troubles with reflection on generic types. To talk more concretely I
> will gvie you some examples of what i´m looking at.
>
> The method where I´m having some troubles needs to do get the generic
> collection type from a generic collection variable. Examples (Please
> forget
> about namespaces, í´m not writing them just to be more clear)
>
> I have My Method
> should return
> List<int> List< >
> type instance
> Dictionary<string, object> Dictionary<> type
> instance
>
> By now I know how to get the parameter types (like int in the first
> example and string and object in the second one) and how to get something
> like List'1<int> or Dictionary'2<string, object> and I know I can parse
> the
> type name as a string and then everything is fixed but I think there is
> some
> whay to get what i´m looking at by using Reflection library. Can someone
> give me a hand?
>
> Thanks in advance.
>
> Fernando
>
>
>
My System SpecsSystem Spec
Old 02-03-2009   #3 (permalink)
Cor Ligthert[MVP]


 
 

Re: Reflection with Generic Collection types

Sorry,

I thought that I was answering from the VB newsgroup.

Cor

"Fernando Arámburu" <fernando@xxxxxx-group.com> wrote in message
news:u1J7ZKghJHA.1184@xxxxxx
Quote:

> hi everybody,
>
> I´m working on a very strange dotnet Reflection component and i´m
> having
> some troubles with reflection on generic types. To talk more concretely I
> will gvie you some examples of what i´m looking at.
>
> The method where I´m having some troubles needs to do get the generic
> collection type from a generic collection variable. Examples (Please
> forget
> about namespaces, í´m not writing them just to be more clear)
>
> I have My Method
> should return
> List<int> List< >
> type instance
> Dictionary<string, object> Dictionary<> type
> instance
>
> By now I know how to get the parameter types (like int in the first
> example and string and object in the second one) and how to get something
> like List'1<int> or Dictionary'2<string, object> and I know I can parse
> the
> type name as a string and then everything is fixed but I think there is
> some
> whay to get what i´m looking at by using Reflection library. Can someone
> give me a hand?
>
> Thanks in advance.
>
> Fernando
>
>
>
My System SpecsSystem Spec
Old 02-09-2009   #4 (permalink)
Fernando Arámburu


 
 

Re: Reflection with Generic Collection types

No problem Cor. Thanks anyway.

Fernando

"Cor Ligthert[MVP]" <Notmyfirstname@xxxxxx> escribió en el mensaje
news:ODslEqjhJHA.5732@xxxxxx
Quote:

> Sorry,
>
> I thought that I was answering from the VB newsgroup.
>
> Cor
>
> "Fernando Arámburu" <fernando@xxxxxx-group.com> wrote in message
> news:u1J7ZKghJHA.1184@xxxxxx
Quote:

>> hi everybody,
>>
>> I´m working on a very strange dotnet Reflection component and i´m
>> having
>> some troubles with reflection on generic types. To talk more concretely I
>> will gvie you some examples of what i´m looking at.
>>
>> The method where I´m having some troubles needs to do get the generic
>> collection type from a generic collection variable. Examples (Please
>> forget
>> about namespaces, í´m not writing them just to be more clear)
>>
>> I have My
>> Method
>> should return
>> List<int> List< >
>> type instance
>> Dictionary<string, object> Dictionary<> type
>> instance
>>
>> By now I know how to get the parameter types (like int in the first
>> example and string and object in the second one) and how to get something
>> like List'1<int> or Dictionary'2<string, object> and I know I can parse
>> the
>> type name as a string and then everything is fixed but I think there is
>> some
>> whay to get what i´m looking at by using Reflection library. Can someone
>> give me a hand?
>>
>> Thanks in advance.
>>
>> Fernando
>>
>>
>>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How to retrieve a generic method with GetMethod (reflection) ? PowerShell
reflection, COM, and Vista .NET General
How to Create Collection Generic Class using new-object PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46