AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 14.11.2012, 01:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,491 / 846 (79) +++++++
Регистрация: 28.10.2006
ax_gfm_framework_team: The Microsoft Dynamics AX 2012 extension framework – Part 3
Источник: http://blogs.msdn.com/b/ax_gfm_frame...rk-part-3.aspx
==============

Arthur Greef and Michael Gall.

In part 1 of this blog entry series, we explained how classes can be extended by using the Microsoft Dynamics AX 2012 extension framework and statically declared class attributes. In part 2, we described the application model elements and application model attributes that are used to extend any application object tree (AOT) object dynamically. In this blog entry, we explain to how to use model attributes and model elements to program dynamic object extensions.

Using model elements as model attributes to program dynamic object extensions

The following example shows how to create a model element object from the DocumentType base enumeration and to then use the model element to create an instance of a model attribute. The resulting model attribute is then used to cache an extension point for the InventoryPolicy1 class.

public void build()

{

SysExtModelElement element;



element = SysExtModelElementAppFactory::newFromEnum(enumNum(DocumentType), DocumentType::Doc1);



SysExtension::addExtension(
SysExtModelElementAppFactory::newFromClassName(classStr(InventoryPolicy1)).parmCacheKey(),
SysExtModelAttributeInstanceFactory::newFromElement(element).parmCacheKey());

}



This extension point could be used to extend the FormLetterJournalCreate class instead of using the FormLetterJournalCreate.newSalesJournalCreate factory method currently implemented in Microsoft Dynamics AX 2012. Both methods use the DocumentType base enumerator to identify class extension points. The extension framework, however, will decouple the base FormLetterJournalCreate declaration from its extensions.

Checking extension design constraints

The SysExtensionValidatorStrategy class can be extended to check that extensions meet design constraints. For example, an extension validator can be used to check if more than one extension point maps the same model element to more than one class extension. An exception can be thrown if a design constraint requires a model element to uniquely identify a class extension.


The extension framework provides the SysExtAppClassUniqueValidator class that enforces a unique model attribute-class extension constraint for all extension classes in a class hierarchy. You can implement your own SysExtensionValidatorStrategy, and in the validate method you can implement additional validation logic (such as, allowing only extensions with particular model attributes, and so on). The validators will be executed after the dynamic builders have been executed.

Runtime extension manipulation

Model attribute extensions can be manipulated at runtime. For example, a model attribute instance that is assigned to a particular model element can be replaced with a different model attribute instance as the following example shows.

static void RuntimeExtension(Args _args)

{

SysExtModelElementApp element;

SysExtModelAttributeInstance attributeInstance;



// Get the element where you want to replace something

element = SysExtModelElementAppFactory::newFromClassName(classStr(PCAdaptor));



// Get the new attribute instance that you would like to set

attributeInstance = SysExtModelAttributeInstanceFactory::newFromValue('NewValue');



// Set for the element the new attribute instance

SysExtension::replace(element, attributeInstance);

}




Источник: http://blogs.msdn.com/b/ax_gfm_frame...rk-part-3.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 8 Blog bot Dynamics CRM: Blogs 1 30.04.2016 10:26
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 10 Blog bot Dynamics CRM: Blogs 0 17.08.2012 03:27
Sample Design Patterns: Book Give-away: 'Microsoft Dynamics AX 2012 Development Cookbook' Blog bot DAX Blogs 1 12.05.2012 16:55
dynamics-ax: Microsoft Highlights New ERP Public Sector Capabilities for AX 2012 Blog bot DAX Blogs 0 23.05.2011 19:11
axinthefield: Dynamics AX Event IDs Blog bot DAX Blogs 0 01.03.2011 22:11
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 03:24.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.