Generate TYPE on-the-fly

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Zoltan Hernyak

    #1

    Generate TYPE on-the-fly

    Hi,

    Can I generate a new type (a class with fields only) on-the-fly, from
    a running app, and use it right then? For example if I want to build
    a class which consists of fields which are parameters of a method.

    I want to write a method which gives a method 'name' as a parameter,
    and construct a class which has the same fields as the method has
    using reflection or something like that... and use the new class
    immediately in the same app. (crazy?!)

    Is it possible?

    Zoltan

  • Ray Hsieh (Ray Djajadinata)

    #2
    Re: Generate TYPE on-the-fly

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Hi Zoltan,

    My question would be "what are you trying to achieve with that?" I mean,
    maybe there is a simpler way of achieving what you want without
    resorting to that.

    If you really really really have to do that, however, may I suggest...
    Python? :)

    Zoltan Hernyak wrote:

    | Hi,
    |
    | Can I generate a new type (a class with fields only) on-the-fly, from
    | a running app, and use it right then? For example if I want to build
    | a class which consists of fields which are parameters of a method.
    |
    | I want to write a method which gives a method 'name' as a parameter,
    | and construct a class which has the same fields as the method has
    | using reflection or something like that... and use the new class
    | immediately in the same app. (crazy?!)
    |
    | Is it possible?
    |
    | Zoltan
    |

    - --
    Ray Hsieh (Ray Djajadinata) [SCJP, SCWCD]
    ray underscore usenet at yahoo dot com
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.3 (MingW32)
    Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

    iD8DBQE/oT4BwEwccQ4rWPg RArGKAJ49iYIT4C Gpy30C1W6BjczIs W0rVQCeLMJz
    ykAsa0dw1hHM/DR1n6xKfSI=
    =5JU5
    -----END PGP SIGNATURE-----

    Comment

    • William Stacey

      #3
      Re: Generate TYPE on-the-fly

      TypeBuilder. See:
      ms-help://MS.VSCC.2003/MS.MSDNQTR.2003 JUL.1033/cpref/html/frlrfsystemrefl ect
      ionemittypebuil dermemberstopic .htm

      --
      William Stacey, MVP

      "Zoltan Hernyak" <aroan@ektf.h u> wrote in message
      news:tic2qvsh2h g718d912avum7an 5hrbqd8il@4ax.c om...[color=blue]
      > Hi,
      >
      > Can I generate a new type (a class with fields only) on-the-fly, from
      > a running app, and use it right then? For example if I want to build
      > a class which consists of fields which are parameters of a method.
      >
      > I want to write a method which gives a method 'name' as a parameter,
      > and construct a class which has the same fields as the method has
      > using reflection or something like that... and use the new class
      > immediately in the same app. (crazy?!)
      >
      > Is it possible?
      >
      > Zoltan
      >[/color]


      Comment

      • Zoltan Hernyak

        #4
        Re: Generate TYPE on-the-fly

        >My question would be "what are you trying to achieve with that?" I mean,[color=blue]
        >maybe there is a simpler way of achieving what you want without
        >resorting to that.[/color]
        using WSE 2, a GetBodyObject( ) method can be used to get all the data
        included into the SOAP body. This method receives only ONE type, and
        generates one instance from that type, fill all the data, then return
        with it. If I see this message is for a method called "Something" ,
        which needs an int and a string, the easiest way :-))) to generate a
        class on-the-fly consist of an int and a string, then call the
        GetBodyObject. When I have the desired (and de-serialized) data,
        I can take care of them, and call the method using some reflection,
        and some brain...

        May be there a run-time code generating stuff in the .NET ?
        [color=blue]
        >If you really really really have to do that, however, may I suggest...
        >Python? :)[/color]

        Of course not :-))) I have to use WSE 2.0 :-)

        Zoltan

        Comment

        • Ray Hsieh (Ray Djajadinata)

          #5
          Re: Generate TYPE on-the-fly

          -----BEGIN PGP SIGNED MESSAGE-----
          Hash: SHA1

          Well, William has the answer for you in his reply below :) (but I love
          Python!) :))

          Zoltan Hernyak wrote:

          | Of course not :-))) I have to use WSE 2.0 :-)
          |
          | Zoltan


          - --
          Ray Hsieh (Ray Djajadinata) [SCJP, SCWCD]
          ray underscore usenet at yahoo dot com
          -----BEGIN PGP SIGNATURE-----
          Version: GnuPG v1.2.3 (MingW32)
          Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

          iD8DBQE/ojYkwEwccQ4rWPg RArVwAJ0Q0pQAM/A5oteZXG73yZOir QraygCfbIp/
          x+L3aQ1HW7gjZP/A4QRupME=
          =ZGVO
          -----END PGP SIGNATURE-----

          Comment

          Working...