|
//cssClass.cs
using System;
using System.Reflection; // ADD THIS.
namespace blah
{
public class callableClass : interfaceExposer
{
public int callableMethodSimple(double a)
{
return (int)a;
}
public int callableMethodArray(object a)
{
double[] thisVect = LoadComObjectIntoDoubleArray(a);
return 7;
}
private double[] LoadComObjectIntoDoubleArray(object comObject)
{
Type thisType = comObject.GetType();
Type dblType = Type.GetType("System.Double[*]");
double[] doubleArray = new double[1]; // temporary allocation to keep compiler happy.
if(thisType == dblType)
{
object[] args = new object[1];
int numEntries = (int)thisType.InvokeMember("Length", BindingFlags.GetProperty, null, comObject, null);
doubleArray = new double[numEntries];
for(int j1=0; j1 < numEntries; j1++)
{
args[0] = j1+1; // since VB arrays index from 1
doubleArray[j1] = (double)thisType.InvokeMember("GetValue", BindingFlags.InvokeMethod, null, comObject, args);
}
} // End if(thisType == dblType)
return doubleArray;
} // End LoadComObjectIntoDoubleArray()
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.