Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to modify the return type of Interface members based on values specified in Using namespace?

$
0
0

Greetings,

I am facing a hurdle while implementing an interface members derived in a custom class. I have used compiler compilation to share codes across each platforms. To avoid reusability, I have used ‘Using’ namespace values to determine the properties across each platforms respectively. The changes across the platforms will be the return type of the members as below.

#if Xamarin_iOS
Using PropertyInfo = System.ComponentModel.PropertyDescriptor;
#endif

Public Interface IClass
{
#if Xamarin_iOS
 PropertyDescriptor GetProperty();
#else
 PropertyInfo GetProperty();
#endif
}

I can remove the compilation for interface members, but I don’t want to break the already existing property name. So what issue am facing here is, when I have inherited this interface in a custom class, I couldn’t able to get the PropertyDescriptor value defined in the Using Namespace, instead it takes the System.Reflection.PropertyInfo value. I have a CustomClass like below in Xamarin forms application:

Public CustomClass:IClass
{
   // Actual Member
   //This actually breaks the existing value.
   Public  PropertyDescriptor GetProperty()
   {
       …..
       return value;
    }

     //Expected member
     //Here PropertyInfo should determine the value specified in the using Namespace(i.e System.ComponentModel.PropertyDescriptor) instead of System.Reflection.PropertyInfo.
     Public  PropertyInfo GetProperty()
   {
       …..
       return value;
    }
}

Can anyone suggest any other suitable approaches to achieve my requirement or enlighten me with a clear solution?

Thanks.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>