c# - How to use GetPropertyValueSafely from CommonLibrary.NET? -
when using commonlibrary.net, how 1 use getpropertyvaluesafely()
function correctly?
i want this:
public static string app_title = comlib.reflectionhelper.getpropertyvaluesafely(application.productname);
but need add second parameter, , don't understand enough yet know asked for. here syntax usage documentation file:
public static object getpropertyvaluesafely( object obj, propertyinfo propinfo )
this parameter requirements:
parameters obj type: system..::..object object property retrieved.
propinfo type: system.reflection..::..propertyinfo property name.
so put object
? tried this, too:
public static string app_title; comlib.reflectionhelper.getpropertyvaluesafely(app_title, application.productname);
but that's not answer either.
i tried this:
public static string app_title = comlib.reflection.reflectionutils.getpropertyvalue((object)app_title, application.productname).tostring();
...which compiles, throws runtime type error library.
thanks (i'm starting stuff head).
try this:
public static readonly string app_title = (string)comlib.reflectionhelper.getpropertyvaluesafely(new object(), comlib.reflection.reflectionutils.getproperty(typeof(application), "productname"));
nb: technically, passing new object()
propertyinfo
's getvalue
method should throw targetexception
. however, since static property, seems work.
Comments
Post a Comment