Позднее связывание и возврат значения ф-ции в параметре (аналог out)

PlayerDN
Дата: 29.01.2010 15:57:47
Работаю через late binding с AutoCAD.

Надо вызвать ф-цию которая в мануале к ВБА описана так:
Acad VBA Manual

GetBoundingBox Method
Gets two points of a box enclosing the specified object.

Signature

object.GetBoundingBox MinPoint, MaxPoint

Object - All Drawing Objects, AttributeReference. The object or objects this method applies to.
MinPoint - Variant (three-element array of doubles); output-only The 3D WCS coordinates specifying the minimum point of the object's bounding box.
MaxPoint - Variant (three-element array of doubles); output-only The 3D WCS coordinates specifying the maximum point of the object's bounding box.


Т.е. результат работы функции возвращается в передаваемых параметрах. На подобии модификатора out в C#.

Я пробую так:
double[] aMinPoint, aMaxPoint;

aMinPoint = new object[3]; aMaxPoint = new object[3];
oCliche.GetType().InvokeMember("GetBoundingBox", BindingFlags.InvokeMethod, null, oCliche, new object[] { aMinPoint, aMaxPoint });
Но бестолку - значения в переданном массиве не изменяются.

Чувствую что где-то надо указать, что функция вернет значение в параметре и ей нужны права на изменений их изменений. Но, блин, не могу найти где это указать.
PlayerDN
Дата: 29.01.2010 16:00:43
Это я переделываю прогу из VB.NET в C#.
В ВБ.НЕТ это описано так, и отлично работает:
        Dim aMinPoint() As Double
        Dim aMaxPoint() As Double

       oCliche.GetBoundingBox(aMinPoint, aMaxPoint)
BlackTomcat
Дата: 29.01.2010 19:13:00
PlayerDN,

Возможно это поможет
MSDN
The ParameterModifier structure is used with the Type.InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[]) method overload when passing parameters by reference to a COM component that is accessed late bound. The parameters that are to be passed by reference are specified by a single ParameterModifier structure, which must be passed in an array containing a single element. The single ParameterModifier structure in this array must be initialized with the number of parameters in the member that is to be invoked. To indicate which of these parameters are passed by reference, set the value of the Item property (the indexer in C#) to true for the index number corresponding to the zero-based position of the parameter.
PlayerDN
Дата: 30.01.2010 09:20:24
BlackTomcat
PlayerDN,

Возможно это поможет


Спасибо, действительно то что нужно.
Но есть ещё один нюанс - как объявить массивы в которых возвратятся результаты работы ф-ции.
Пол дня подбирал, но все таки нашел (не без помощи такой-то матери).

Незнаю это фича автокада или это касается всех функций которые возвращают значение в параметра, но приведу пример на всякий случай, может кому-то пригодится.
object[] Params;
object aMinPoint = null, aMaxPoint = null;
ParameterModifier p = new ParameterModifier(2);
p[0] = true;
p[1] = true;
Params = new object[] { aMinPoint, aMaxPoint };

oCliche.GetType().InvokeMember("GetBoundingBox", BindingFlags.InvokeMethod, null, oCliche, Params, new ParameterModifier[] { p }, null, null);

Т.е. передаваеммые массивы должны быть именно Object'ами и неинициализированными (null) если это не так будет исключение "Неверно задана вызываемая сторона. (Исключение из HRESULT: 0x80020010 (DISP_E_BADCALLEE))".

Удачи.