|
![]() |
#1 |
Читатель
|
Цитата:
X++: type = myIntList.GetType(); propertyCount = type.GetProperty("Count"); nil = new System.Object[0](); cnt = propertyCount.GetValue(myIntList, nil); info(strFmt("%1", cnt)); |
|
|
За это сообщение автора поблагодарили: Cardagant (1). |
![]() |
#2 |
Участник
|
Спасибо за ответ! Но всё равно не выходит.
Попробую привести ситуацию подробнее TMSoft.Gohub.Client.GohubConnection - Класс сборки, реализующий подключение к сторонней БД TMSoft.Gohub.Client.GohubDocument - Класс сборки, реализующий объекты, коллекцию которых требуется получить. X++: System.Type enumerable; System.Type enumerator; System.Object CLRenumerable; System.Object CLRenumerator; System.Reflection.MethodInfo methodInfo; ; // Создаётся некоторое подключение con = new TMSoft.Gohub.Client.GohubConnection(someparams); // Получить коллекцию всех документов // Описание функции говорит, что возвратит System.Collections.Generic.IEnumerable`1[TMSoft.Gohub.Client.GohubDocument] CLRenumerable = con.QueryDocuments(0); // Получить тип enumerable = CLRenumerable.GetType(); info(enumerable.get_Name()); // <_QueryDocuments>d__0 info(enumerable.get_FullName()); // TMSoft.Gohub.Client.GohubConnection+<_QueryDocuments>d__0 info(enumerable.get_AssemblyQualifiedName()); // TMSoft.Gohub.Client.GohubConnection+<_QueryDocuments>d__0, TMSoft.Gohub.Client.Net, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null if (CLRInterop::isNull(enumerable)) // false throw error("null"); methodInfo = enumerable.GetMethod("GetEnumerator"); if (CLRInterop::isNull(methodInfo)) // true throw error("null"); CLRenumerator = methodInfo1.Invoke(enumerable, nil); Последний раз редактировалось Cardagant; 28.10.2013 в 13:18. |
|
![]() |
#3 |
Читатель
|
Может все же
X++: CLRenumerator = methodInfo.Invoke(CLRenumerable, nil); Последний раз редактировалось b_nosoff; 28.10.2013 в 15:16. |
|
![]() |
#4 |
Участник
|
Цитата:
Закоментировал проверку на Нулл, получаю ошибку на строке X++: CLRenumerator = methodInfo.Invoke(CLRenumerable, nil); Последний раз редактировалось Cardagant; 28.10.2013 в 14:25. |
|
![]() |
#5 |
Читатель
|
Попробуйте так:
X++: enumerable = System.Type::GetType("System.Collections.IEnumerable"); |
|
![]() |
#6 |
Участник
|
Благодарю Вас, b_nosoff
Вы мне очень помогли. Привожу код рабочего метода, в котором получаю XML-текст первого документа. Мне нужен цикл, его, естественно, доделаю. Очень благодарен всем, кто помог! docum - это класс документа, определённый в сборке (TMSoft.Gohub.Client.GohubDocument) X++: con = new TMSoft.Gohub.Client.GohubConnection("localhost", 20295); CLRenumerable = con.QueryDocuments(0); // Получить тип //enumerable = CLRenumerable.GetType(); enumerable = System.Type::GetType("System.Collections.IEnumerable"); if (CLRInterop::isNull(enumerable)) // false throw error("null"); methodInfo = enumerable.GetMethod("GetEnumerator"); /*if (CLRInterop::isNull(methodInfo)) // true throw error("null");*/ CLRenumerator = methodInfo.Invoke(CLRenumerable, nil); if (CLRInterop::isNull(CLRenumerator)) throw error("null"); enumerator = System.Type::GetType("System.Collections.IEnumerator"); methodInfo = enumerator.GetMethod("MoveNext"); // Переход к первому элементу b = methodInfo.Invoke(CLRenumerator, nil); // считывание текущего элемента if (b) { // Сичтываю свойство с текущим документом ParameterInfo = enumerator.GetProperty("Current"); // Получение текущего элемента docum = ParameterInfo.GetValue(CLRenumerator, nil); // ПОлучение документа в формате XML info(docum.GetXmlText()); } Последний раз редактировалось Cardagant; 28.10.2013 в 17:40. |
|
|
За это сообщение автора поблагодарили: Logger (5), MazZzDaI (1). |
Теги |
.net, generic |
|
|