c# - In WinRT, how to Reflect for Properties that implement an Interface? -


sometimes, in windows runtime want return list of class properties implement interface. unfortunately, of .net helper methods made possible missing or moved. how reflect properties implement interface?

like this:

using system.reflection;  /// <summary>finds properties implement type</summary> /// <param name="parent">the parent type</param> /// <param name="type">the filter type</param> /// <returns>enumerable of propertyinfo</returns> ienumerable<propertyinfo> properties(type parent, type type) {     var typeinfo = type.gettypeinfo();     var properties = parent.getruntimeproperties();     foreach (propertyinfo property in properties)     {         var propertytypeinfo = property.propertytype.gettypeinfo();         if (typeinfo.isassignablefrom(propertytypeinfo))             yield return property;     } } 

best of luck!


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -