Re: Getting object properties from interface reference

From: Peter Rilling (peter_at_nospam.rilling.net)
Date: 09/17/04


Date: Thu, 16 Sep 2004 19:39:29 -0700

You could try using reflection, but you will not be able to early bind your
method calls because, as you are aware, the compiler only sees the interface
members.

"Andrey" <leyandrew@yahoo.com> wrote in message
news:Drp2d.57093$MQ5.10885@attbi_s52...
> Hi,
>
> Here's the problem:
> Say a have a class, implementing an interface:
>
> // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
> public class GraphClass : IGraphInterface
> {
> public string Property1 {
> get {
> return value1;
> }
> set {
> value1 = value; }
> }
>
> public string Property2 {
> get {
> return value2;
> }
> set {
> value2 = value; }
> }
> /*Some other code*/
> }
> // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Say, somewhere in my progarm i do the following:
>
> IGraphInterface gc = new GraphClass();
>
> Is there a way to get a list of properties (Property1, Property2, etc)
> along with their names
> (if possible) from the instance 'gc', if it's referenced as interface,
> like in the example?
> I can assume that yes, because it's done somehow by VS IDE, when you use
> UserControls, where you can define a property which will appear in
> "Properties" toolbar.
>
>
> Any ideas would be highly appreciated!
>
> Thank you in advance,
> Andrey



Relevant Pages

  • RESULT attribute not working
    ... BIND RESULT ... IMPLICIT NONE ... Having this interface block verbatim in the calling program, ... IntelC Compiler for applications running on Intel64, ...
    (comp.lang.fortran)
  • Re: MFC and c++ problems
    ... compiler to generate code that is architecturally nonsensical. ... So a design in which a control has any syntactic knowledge of any container of itself ... GetParent->SendMessage is the interface of choice, ...
    (microsoft.public.vc.mfc)
  • Re: Win32 API and gfortran
    ... write out a module containing only interface blocks and compile the ... that the /iface switches and ATTRIBUTES directives change the compiler ... arguments are passed in the normal Fortran way ...
    (comp.lang.fortran)
  • Re: Using early-bound interface on a late-bound object
    ... > the compiler determines which interfaces to use, ... > supports the declared interface. ... >> help if someone can point me to some authoritative document or reference ... within customer shops when they mirrored this 'division' to keep their ...
    (microsoft.public.vb.general.discussion)
  • Re: Some OO design principles WAS Re: Differences in data description in programming languages
    ... Late binding means it is resolved at run time. ... Conformance is a quality that applies to interfaces. ... * An interface can also be a collection of method prototypes, ... the Compiler provides conformance checking. ...
    (comp.lang.cobol)