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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 20.01.2010, 08:32   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
X++: Traversing elements in an IEnumerable from X++
Источник: http://blogs.msdn.com/x/archive/2010...le-from-x.aspx
==============

This issue recently came up: How do you traverse the elements in an instance of an IEnumerable from X++?

The answer is not as simple as it should be. The problem is that the X++ language does not currently support generics as a firstclass part of the managed X++ story. This means that we need to do some tricks to make this work. At least it shows off the capabilities of the ClrObject class: It can take a string that designates the type that you want to create an instance of. The CLR runtime system is so cleverly designed that it allows decorating types so they designate generic types. This is done by appending the backtick character, followed by the number of generic arguments, enclosed by the argument types enclosed in angular brackets.

So, the type

System.Collections.Generic.List

is represented as

System.Collections.Generoc.List`1[System.Int]

With this knowledge the task is not hard:



static void GenericTypeDemo(Args _args) { ClrObject o = new ClrObject("System.Collections.Generic.List`1[System.Int32]"); ClrObject enumerator; int theValue; // o is an instance of an IEnumerable o.Add(1); o.Add(4); o.Add(12); print o.ToString(); enumerator = o.GetEnumerator(); while (enumerator.MoveNext()) { theValue = enumerator.get_Current(); print theValue; } pause; }



Источник: http://blogs.msdn.com/x/archive/2010...le-from-x.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
dynamic-ax.co.uk: Import Emails from Outlook 2007 into Dynamics AX 2009 Blog bot DAX Blogs 1 03.07.2009 07:17
Разница NotInTTS и Found Logger DAX: База знаний и проекты 6 18.09.2008 12:35
Khue Trinh: AX 2009 Quality Management - Quality Control Blog bot DAX Blogs 1 04.07.2008 16:01
Вопрос про Demand Planner slava09 DAX: Функционал 4 25.09.2006 11:43
Говорят вышел SP2 для Axapta 3. Кто нибуть что знает на эту тему? soin DAX: Прочие вопросы 10 13.10.2003 10:43

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

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

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 23:33.