Windows Vista Forums

Reflection with Generic Collection types

  1. #1


    Fernando Armburu Guest

    Reflection with Generic Collection types

    hi everybody,

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

    The method where Im 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 im looking at by using Reflection library. Can someone
    give me a hand?

    Thanks in advance.

    Fernando




      My System SpecsSystem Spec

  2.   


  3. #2


    Cor Ligthert[MVP] Guest

    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 Armburu" <fernando@xxxxxx-group.com> wrote in message
    news:u1J7ZKghJHA.1184@xxxxxx

    > hi everybody,
    >
    > Im working on a very strange dotnet Reflection component and im
    > having
    > some troubles with reflection on generic types. To talk more concretely I
    > will gvie you some examples of what im looking at.
    >
    > The method where Im 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 im looking at by using Reflection library. Can someone
    > give me a hand?
    >
    > Thanks in advance.
    >
    > Fernando
    >
    >
    >

      My System SpecsSystem Spec

  4. #3


    Cor Ligthert[MVP] Guest

    Re: Reflection with Generic Collection types

    Sorry,

    I thought that I was answering from the VB newsgroup.

    Cor

    "Fernando Armburu" <fernando@xxxxxx-group.com> wrote in message
    news:u1J7ZKghJHA.1184@xxxxxx

    > hi everybody,
    >
    > Im working on a very strange dotnet Reflection component and im
    > having
    > some troubles with reflection on generic types. To talk more concretely I
    > will gvie you some examples of what im looking at.
    >
    > The method where Im 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 im looking at by using Reflection library. Can someone
    > give me a hand?
    >
    > Thanks in advance.
    >
    > Fernando
    >
    >
    >

      My System SpecsSystem Spec

  5. #4


    Fernando Armburu Guest

    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

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

    >> hi everybody,
    >>
    >> Im working on a very strange dotnet Reflection component and im
    >> having
    >> some troubles with reflection on generic types. To talk more concretely I
    >> will gvie you some examples of what im looking at.
    >>
    >> The method where Im 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 im looking at by using Reflection library. Can someone
    >> give me a hand?
    >>
    >> Thanks in advance.
    >>
    >> Fernando
    >>
    >>
    >>
    >


      My System SpecsSystem Spec


Reflection with Generic Collection types
Similar Threads
Thread Forum
How to retrieve a generic method with GetMethod (reflection) ? PowerShell
Question on Reflection .NET General
Converting proxy generated types to original types Indigo
How to Create Collection Generic Class using new-object PowerShell
Re: reflection with a viewport3D Avalon