Показать сообщение отдельно
Старый 21.05.2009, 12:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,497 / 847 (79) +++++++
Регистрация: 28.10.2006
SysDictCoder: Detecting default values
Источник: http://sysdictcoder.com/blog/detecting-default-values/
==============

So I haven’t posted in a long time. I finally fixed some technical issues on the blog and upgraded to a recent version of Wordpress. Let’s start with a quick tip to warm up :)

As you know X++ supports methods with default values. In Ax it’s possible to detect when such a default value was used at runtime with prmIsDefault(). To see this for yourself, create a class with a method like this:

void someMethod(int i = 1) { ; if (prmIsDefault(i)) { info('Default'); } else { info('Value given'); } }

And call it from another method.

o.someMethod(); o.someMethod(1);

Even though the value is the same in both cases a different info message will be displayed.

Now you may be wondering how this can be useful. Some scenarios:

  • Avoiding expensive operations if the default value was used
  • Avoiding unwanted initializations
  • Dealing with customizations that require extra parameters in standard Ax classes
If you do a search for prmIsDefault() in the AOT you will see it’s used often. Classes with the Ax prefix are the most obvious example. Because getters and setters are rolled into a single method it’s necessary to know if the method was used as a getter or a setter and keep track of modified fields.



Источник: http://sysdictcoder.com/blog/detecting-default-values/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.