FormHasMethod extension in D365FO
Validating FORM HasMethod on Run time, including Form Extension HasMethod also in D365 FO
Class:
Global
Method:
formHasMethod
COC ->
using System.Object;
using Microsoft.Dynamics.Ax.Xpp;
using System.Reflection;
[ExtensionOf(classStr(Global))]
final class Global_Extension
{
static boolean formHasMethod(FormRun _fromRun, IdentifierName _methodName)
{
boolean flag = next formHasMethod(_fromRun, _methodName);
if (flag==false)
{
flag= Global::VerifyformExtensionHasMethod(_fromRun, _methodName);
}
return flag;
}
private static boolean VerifyformExtensionHasMethod(FormRun _formRun, IdentifierName _methodName)
{
try
{
System.Object[] extensions = ExtensionClassSupport::GetExtensionsOnType(_formRun.GetType(), true);
if (extensions)
{
System.Type formExtensionType;
MethodInfo mInfo;
var bindingFlags = BindingFlags::Public | BindingFlags::Static | BindingFlags::IgnoreCase;
for (int i = 0; i < extensions.Length; i++)
{
formExtensionType = extensions.GetValue(i);
var info = formExtensionType.GetMethods(bindingFlags);
for (int J = 0; J < info .get_Length(); J++)
{
mInfo= info .getValue(J);
if (mInfo.Name == _methodName)
{
return true;
}
}
}
}
}
catch (Exception::CLRError)
{
error(CLRInterop::getLastException().ToString());
}
return false;
}
}
Validating FORM HasMethod on Run time, including Form Extension HasMethod also in D365 FO
Class:
Global
Method:
formHasMethod
COC ->
using System.Object;
using Microsoft.Dynamics.Ax.Xpp;
using System.Reflection;
[ExtensionOf(classStr(Global))]
final class Global_Extension
{
static boolean formHasMethod(FormRun _fromRun, IdentifierName _methodName)
{
boolean flag = next formHasMethod(_fromRun, _methodName);
if (flag==false)
{
flag= Global::VerifyformExtensionHasMethod(_fromRun, _methodName);
}
return flag;
}
private static boolean VerifyformExtensionHasMethod(FormRun _formRun, IdentifierName _methodName)
{
try
{
System.Object[] extensions = ExtensionClassSupport::GetExtensionsOnType(_formRun.GetType(), true);
if (extensions)
{
System.Type formExtensionType;
MethodInfo mInfo;
var bindingFlags = BindingFlags::Public | BindingFlags::Static | BindingFlags::IgnoreCase;
for (int i = 0; i < extensions.Length; i++)
{
formExtensionType = extensions.GetValue(i);
var info = formExtensionType.GetMethods(bindingFlags);
for (int J = 0; J < info .get_Length(); J++)
{
mInfo= info .getValue(J);
if (mInfo.Name == _methodName)
{
return true;
}
}
}
}
}
catch (Exception::CLRError)
{
error(CLRInterop::getLastException().ToString());
}
return false;
}
}
No comments:
Post a Comment