03.08.2018, 18:11 | #1 |
Участник
|
d365technext: FormHasMethod extension in D365FO
Источник: http://d365technext.blogspot.com/201...in-d365fo.html
============== FormHasMethod extension in D365FO Every developer who has start working on D365FO face this issue that when we create method in form Extension For verification of method exists or not in run time we can use Global::formHasMethod but it does not work with form extensions So i advise everyone to use below code its working... [ExtensionOf(classStr(Global))] finalclass SLD_Global_Extension { staticboolean formHasMethod(FormRun _formRun, IdentifierName _methodName) { boolean ret = next formHasMethod(_formRun, _methodName); if (!ret) { ret = Global::VerifyformHasMethod((_formRun, _methodName); } return ret; } privatestaticboolean VerifyformHasMethod (FormRun _formRun, IdentifierName _methodName) { try { System.Object[] extensions = Microsoft.Dynamics.Ax.Xpp.ExtensionClassSupport::GetExtensionsOnType(_formRun.GetType(), true); if (extensions) { System.Type formRunExtensionType; System.Reflection.MethodInfo methodInfo; //extension methods are always static var bindingFlags = BindingFlags::Public | BindingFlags::Static | BindingFlags::IgnoreCase; for (int i = 0; i < extensions.Length; i++) { formRunExtensionType = extensions.GetValue(i); var methodsInfo = formRunExtensionType.GetMethods(bindingFlags); for (int n = 0; n < methodsInfo.get_Length(); n++) { methodInfo = methodsInfo.getValue(n); if (methodInfo.Name == _methodName) { returntrue; } } } } } catch (Exception::CLRError) { error(CLRInterop::getLastException().ToString()); } returnfalse; } } Источник: http://d365technext.blogspot.com/201...in-d365fo.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|