reflection uses

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

    reflection uses

    hi
    could any one tell me which real life senarios reflection can be used in ?
    thnx


  • guy

    #2
    RE: reflection uses

    the VS.NET debugger :-)

    "Frazer" wrote:
    [color=blue]
    > hi
    > could any one tell me which real life senarios reflection can be used in ?
    > thnx
    >
    >
    >[/color]

    Comment

    • Greg Young

      #3
      Re: reflection uses

      sure ....

      how about default serialization of objects ?

      how about the databinding of classes to display objects ?

      by being able to get the description of an object one can do many things ...

      Greg


      "Frazer" <Frazer@hotmail .com> wrote in message
      news:OBVY4lpXEH A.1656@TK2MSFTN GP09.phx.gbl...[color=blue]
      > hi
      > could any one tell me which real life senarios reflection can be used in ?
      > thnx
      >
      >[/color]


      Comment

      • Frazer

        #4
        Re: reflection uses

        what can i use it for.
        I just want to create some samples of reflection.
        I have created a utility.
        i have a class and some methods have an attribute called "Storedprocedur e"
        which takes as a parameter the stored procedure name .
        i then use reflection to find out those methods that have these attributes.

        and check if the db has those stored procedures or someone has accidently
        deleted them.

        this is quite useful. but i cant think of any other ways that i can use
        reflection.
        what do u mean by default serialization of objects?
        and how about the databinding of classes to display objects ?
        can u elaborate a bit more thanx?



        "Greg Young" <greg.young@pla netbeach.com> wrote in message
        news:#tCDY$rXEH A.644@TK2MSFTNG P10.phx.gbl...[color=blue]
        > sure ....
        >
        > how about default serialization of objects ?
        >
        > how about the databinding of classes to display objects ?
        >
        > by being able to get the description of an object one can do many things[/color]
        ....[color=blue]
        >
        > Greg
        >
        >
        > "Frazer" <Frazer@hotmail .com> wrote in message
        > news:OBVY4lpXEH A.1656@TK2MSFTN GP09.phx.gbl...[color=green]
        > > hi
        > > could any one tell me which real life senarios reflection can be used in[/color][/color]
        ?[color=blue][color=green]
        > > thnx
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Sean Bright

          #5
          Re: reflection uses

          Create a simple console application that defines a IPlugin interface of
          some kind, say something like this:

          public interface IPlugin
          {
          void PerformSomeActi on(System.IO.Te xtWriter output);
          }

          Then create "class library" assemblies that have classes that implement
          said interface:

          public class HelloWorldPlugi n : MyConsoleApplic ation.Whatever. IPlugin
          {
          public HelloWorldPlugi n()
          {
          }

          public void PerformSomeActi on(System.IO.Te xtWriter output)
          {
          output.WriteLin e("Hello, World!");
          }
          }

          public class GoodbyeWorldPlu gin : MyConsoleApplic ation.Whatever. IPlugin
          {
          public GoodbyeWorldPlu gin()
          {
          }

          public void PerformSomeActi on(System.IO.Te xtWriter output)
          {
          output.WriteLin e("Goodbye, cruel... cruel... World!");
          }
          }

          Then use reflection to load those assemblies at run-time, and call the
          PerformSomeActi on() method on the classes, passing Console.Out or
          something along those lines.

          Something like that?

          Good luck,
          Sean

          Frazer wrote:
          [color=blue]
          > what can i use it for.
          > I just want to create some samples of reflection.
          > I have created a utility.
          > i have a class and some methods have an attribute called "Storedprocedur e"
          > which takes as a parameter the stored procedure name .
          > i then use reflection to find out those methods that have these attributes.
          >
          > and check if the db has those stored procedures or someone has accidently
          > deleted them.
          >
          > this is quite useful. but i cant think of any other ways that i can use
          > reflection.
          > what do u mean by default serialization of objects?
          > and how about the databinding of classes to display objects ?
          > can u elaborate a bit more thanx?
          >
          >
          >
          > "Greg Young" <greg.young@pla netbeach.com> wrote in message
          > news:#tCDY$rXEH A.644@TK2MSFTNG P10.phx.gbl...
          >[color=green]
          >>sure ....
          >>
          >>how about default serialization of objects ?
          >>
          >>how about the databinding of classes to display objects ?
          >>
          >>by being able to get the description of an object one can do many things[/color]
          >
          > ...
          >[color=green]
          >>Greg
          >>
          >>
          >>"Frazer" <Frazer@hotmail .com> wrote in message
          >>news:OBVY4lpX EHA.1656@TK2MSF TNGP09.phx.gbl. ..
          >>[color=darkred]
          >>>hi
          >>>could any one tell me which real life senarios reflection can be used in[/color][/color]
          >
          > ?
          >[color=green][color=darkred]
          >>>thnx
          >>>
          >>>[/color]
          >>
          >>[/color]
          >
          >[/color]

          Comment

          • Eddie de Bear

            #6
            RE: reflection uses

            Reflection..

            One of the things I have used reflection for was to create a better Comparer. The comparer I created alows me to sort my own custom collection based on a string array of fields. Works really well

            Another thing I use reflection for is for Generic validation. Most of my business objects have custom attributes such as "Required", Min/Max Values etc that are retrieved by reflection from an Extender control. This allows me to bind business objects directly to the UI and still define these requirements in a single central location.

            These are just some of the places I use reflection almost every day.
            --
            Eddie de Bear
            MCSD


            "Frazer" wrote:
            [color=blue]
            > hi
            > could any one tell me which real life senarios reflection can be used in ?
            > thnx
            >
            >
            >[/color]

            Comment

            Working...