Ok, I have a dotnet dll that I can now access via com (thanks to Rick Strahl's article) in VFP like so:
oP = CREATEOBJECT("a.CachStandard.API.oneClass","","")
public lnport
lnport = 5000
llResult = op.connect(lnport)
I can view the interfaces and members like so:
otlb=otli.TypeLibInfoFromFile("a.CachStandard.API.oneClass.tlb")
FOR each oCoClass in otlb.CoClasses
?" ",oCoClass.name
for each oInterface in oCoClass.Interfaces
?" ",oInterface.name
endfor
endfor
?
?"Interfaces"
FOR each oInterface in otlb.Interfaces
?" ",oInterface.name
ENDFOR
?
?"Interface Members for 1st interface"
FOR each oMember IN otlb.Interfaces(1).Members
?" ", oMember.name
FOR each oParm in oMember.Parameters
?" ",oParm.name
ENDFOR
ENDFOR
So I know it exists and is accessible from vfp. Now I need to pass information to one of its methods but the parameter is an object which contains many props and collections.
A sesssion class is created which looks like this in c#:
public class CACHSessionClass
{
bool _Connected;
string _IP;
int _Port;
Guid _aCallID;
aClass _aRCalls;
aScriptClass _aScript;
aLogClassCollection _aLog;
aRecommendationClass _aRecom;
aImageClassCollection _aImages;
aStatusEnum _aStatus;
string _aTypeCode;
then:
Now the problem: some of the members of the above CACHSessionClass are classes or collections. For example, here is aClass:
[Serializable]
public class aClass
{
public aClass();
public aClass(int PSAP, int aPosition, DateTime aCallDateTime);
public aClass(string aName, string aTeleNumber, double aLatitude, string aLocation,
);
public aClassCollection AliFields { get; set; }
public int aPosition { get; set; }
public Guid aCallID { get; set; }
public string aTeleNumber { get; set; }
public DateTime aCallDateTime { get; set; }
public string aLocation { get; set; }
public double aAltitude { get; set; }
public string aName { get; set; }
public int PSAP { get; set; }
public bool IsEqual(aClass ANIALI);
}
and in turn, the aClassCollection in the above is a collection:
[Serializable]
public class aClassCollection : CollectionBase
{
public aClassCollection();
public aField this[int index] { get; set; }
public int Add(aField value);
public void Clear();
public bool Contains(aField value);
public aField FindByFieldName(string FieldName);
public int IndexOf(aField obj);
public void Insert(int index, aField value);
public void Remove(aField obj);
public void RemoveAt(int index);
}
and in turn, afield in aClassCollection above is like so:
[Serializable]
public class aField
{
public aField();
public aField(string Name, string Value);
public string Name { get; set; }
public string Value { get; set; }
}
and on and on and on...
A new aClass is created like so in c#:
private void CreateSampleaClass()
{
aClass call0 = new aClass();
call0.ID = Guid.NewGuid().ToString();
call0.CACHCallID = Guid.Empty;
call0.aCallDateTime = DateTime.Now;
call0.aFields = new aClassCollection();
call0.aName= "A";
call0.aTeleNumber= "23465723463";
call0.aLocation= "location";
etc.......
Can anyone help me get started? I think I need to create a session probably like so:
PUBLIC oaClass
oaClass = NEWOBJECT('aClass',"a.CachStandard.API.oneClass.tlb")
DEFINE CLASS aClass AS session OLEPUBLIC
IMPLEMENTS aClass IN "a.CachStandard.API.oneClass.tlb"
ENDDEFINE
But that returns the error: "Class cannot be instantiated because Member 'aClass_get_ToString' does not exist.
aclass does contain a ToString property
Or am I on the wrong track?
UPDATE: This seems to be working for setting the props (that are simple strings or int or guids):
Public loAPI as a.CachStandard.API.oneClass.aClass
loAPI = CREATEOBJECT("a.CachStandard.API.oneClass.aClass","","")
loAPI.ID = '00000000-0000-0000-0000-000000000000'
loAPI.aTeleNumber = '1234567890'
loAPI.alocation = '100 N Main St;HP'
But I still need to set objects and collections and pass them...
.·*´¨)
.·`TCH
(..·*
010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"