Muchas Gracias.

En mi caso queda:

TryCast(miControl, IValidate) y si no implementa la interfaz Ivalidate
devuelve Nothing.

 

Carlos Marcelo Santos.

 

   _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Daniel
Calvin
Sent: Viernes, 24 de Agosto de 2007 10:38 a.m.
To: [email protected]
Subject: [puntonet] Saber si un objeto implementa una interface (Ex: OT rdp)

 

Gracias Diego

El día 24/08/07, Diego Cepero <HYPERLINK
"mailto:[EMAIL PROTECTED]"[EMAIL PROTECTED]> escribió:

Existe… se llama TryCast.

Saludos.

 

   _____  

De: Daniel Calvin [mailto:HYPERLINK "mailto:[EMAIL PROTECTED]"
[EMAIL PROTECTED] 
Enviado el: Viernes, 24 de Agosto de 2007 09:57
Para: HYPERLINK "mailto:[email protected]"; [EMAIL PROTECTED]
Asunto: [puntonet] Saber si un objeto implementa una interface (Ex: OT rdp)

 

Una aporte mas a la confusión general....

Les cuento algo que existe en c#, no se si esta disponible en vb, el
operador as..

En C# uno podria hacer una conversion de tipo segura, evitando una exception
verificando primero con is, ejemplo: 

            IServiceProvider isp=null;
            if (this is IServiceProvider)
                ips = (IServiceProvider)this;

Una forma mas elegante, y tambien mas eficiente si miran el codigo msil
resultante, es usar el operador as, ejemplo: 

            IServiceProvider isp = this as IServiceProvider;

Esto último hace lo mismo que el ejemplo anterior, si this no implementa
IServiceProvider ips valdra null.  :))

Saben si hay equivalente en vb???, busque y no lo encontre.... 

Bueno, me parecio que valia la pena....  :))

Saludos

Daniel Calvin

El día 24/08/07, Luis Capra <HYPERLINK "mailto:[EMAIL PROTECTED]" \n
[EMAIL PROTECTED]> escribió:

Yo para hacer eso, en C# hice un metodo:

 

        public static bool IsInterfaceImplemented(Type type, Type
interfaceType)
        {
            return type.FindInterfaces(
                       new TypeFilter(
                           delegate(Type _type, object _filter) 
                               {
                                   return (_type.Name == ((Type)
_filter).Name) &&
                                          (_type.Namespace == ((Type)
_filter).Namespace); 
                               }
                           ),
                       interfaceType
                       ).Length == 1;
        }

Peor por lo visto es mucho mas sencillo lo otro :=)

 



 

On 8/24/07, Carlos Marcelo Santos <HYPERLINK
"mailto:[EMAIL PROTECTED]" [EMAIL PROTECTED] > wrote: 

¡¡¡Muchas Gracias!!!

Auspiciosa manera de comenzar un viernes…

 

Carlos Marcelo Santos.

 

   _____  

From: HYPERLINK "mailto:[email protected]"; [EMAIL PROTECTED]
[mailto:HYPERLINK "mailto:[email protected]"; [EMAIL PROTECTED] On
Behalf Of HYPERLINK "mailto:[EMAIL PROTECTED]" [EMAIL PROTECTED]
Sent: Viernes, 24 de Agosto de 2007 02:39 a.m. 


To: HYPERLINK "mailto:[email protected]"; [EMAIL PROTECTED] 
Subject: [puntonet] Saber si un objeto implementa una interface (Ex: OT rdp)

 

If TypeOf miControl Is ISerializable Then 

 

Saludos

Leonardo

 

   _____  

De: Carlos Marcelo Santos [mailto: HYPERLINK
"mailto:[EMAIL PROTECTED]" [EMAIL PROTECTED] 
Enviado el: Jueves, 23 de Agosto de 2007 09:53 p.m.
Para: HYPERLINK "mailto:[email protected]"; [EMAIL PROTECTED] 
Asunto: [puntonet] Saber si un objeto implementa una interface (Ex: OT rdp) 

 

* Replies will be sent through Spamex to HYPERLINK
"mailto:[email protected]"; [EMAIL PROTECTED] 
* For additional info click -> HYPERLINK
"http://www.spamex.com/i/?v=13137989"; \nwww.spamex.com/i/?v=13137989 

 

Hola Diego:

Gracias por prolijar el subject.

No funciona para este caso

If miControl Is ISerializable Then

Da error

Y ahora probé

If miControl = ISerializable Then

También da error

 

Gracias.

 

Carlos Marcelo Santos .

 

   _____  

From: HYPERLINK "mailto:[email protected]"; [EMAIL PROTECTED]
[mailto:HYPERLINK "mailto:[email protected]"; [EMAIL PROTECTED] On
Behalf Of Diego Jancic
Sent: Jueves, 23 de Agosto de 2007 09:42 p.m.
To: HYPERLINK "mailto:[email protected]"; [EMAIL PROTECTED]
Subject: [puntonet] Saber si un objeto implementa una interface (Ex: OT rdp)


 

Hola,

Cambie el asunto del email para que se entienda un poco mas de que estamos
hablando… 

 

Según un traductor de C# a HYPERLINK "http://vb.net/"; \nVB.NET, esto:

 

bool a = myControl is ISerializable;

 

se traduce a esto:

 

Dim a As Boolean = (myControl = ISerializable)

 

 

Espero que te sirva.

 

Saludos,
Diego

 

 

   _____  

From: HYPERLINK "mailto:[email protected]"; [EMAIL PROTECTED]
[mailto:HYPERLINK "mailto:[email protected]"; [EMAIL PROTECTED] On
Behalf Of Carlos Marcelo Santos
Sent: Jueves, 23 de Agosto de 2007 09:34 p.m.
To: HYPERLINK "mailto:[email protected]"; [EMAIL PROTECTED]
Subject: [puntonet] OT rdp

 

Hola Gente:

¿Cómo se pregunta en VB si un objeto implementa una interface?

Lo que en C# sería

if (myControl is ISerializable)

 

Gracias.

 

Carlos Marcelo Santos .

 

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.484 / Virus Database: 269.12.2/967 - Release Date: 22/08/2007
06:51 p.m.

 

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.484 / Virus Database: 269.12.2/967 - Release Date: 22/08/2007
06:51 p.m.

 

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.484 / Virus Database: 269.12.2/967 - Release Date: 22/08/2007
06:51 p.m.

 

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.484 / Virus Database: 269.12.2/967 - Release Date: 22/08/2007
06:51 p.m.

 

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.484 / Virus Database: 269.12.2/967 - Release Date: 22/08/2007
06:51 p.m.

 

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.484 / Virus Database: 269.12.2/967 - Release Date: 22/08/2007
06:51 p.m.

 




-- 
Daniel A. Calvin
Cooperator Team Member
HYPERLINK "http://www.cooperator.com.ar"; \nhttp://www.cooperator.com.ar
Microsoft Certified Professional 




-- 
Daniel A. Calvin
Cooperator Team Member
HYPERLINK "http://www.cooperator.com.ar"http://www.cooperator.com.ar
Microsoft Certified Professional 

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.484 / Virus Database: 269.12.4/969 - Release Date: 23/08/2007
04:04 p.m.


No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.484 / Virus Database: 269.12.4/969 - Release Date: 23/08/2007
04:04 p.m.
 

Responder a