.Net Interop: example in using arrays/collections

Administrator
Member, Moderator, Administrator Posts: 2,506
.Net Interop: example in using arrays/collections
I just created this example to explain how .Net Interop can be used what you need Arrays.
You can read all about it on my blog.
http://www.mibuso.com/dlinfo.asp?FileID=1342
Discuss this download here.
I just created this example to explain how .Net Interop can be used what you need Arrays.
You can read all about it on my blog.
http://www.mibuso.com/dlinfo.asp?FileID=1342
Discuss this download here.
0
Comments
-
This example code and the related blog post are an excellent example of some of the simple power that can come from using the base .NET framework inside NAV. The beauty of using base .NET functionality is that base platform is freely available and normally already required to be installed on servers and machines already - which means no custom COM Controls or DLL files that need to be managed and rolled out.
Great simple example and I can't wait to see some more complex examples of .NET interop!!0 -
Passing an array of BSTR (or whatever COM-type) from NAV by COM-interop would be nice0
-
I am having some problems with the DotNet Idictionary. The code in In your example:
BEGIN dict := dict.Dictionary(); dict.Add(1,'one'); dict.Add(2,'two'); FOR i := 1 TO dict.Count() DO BEGIN dict.TryGetValue(i,mytext); MESSAGE(mytext); END;
But what if you do not know the key value, and you just want to iterate and print all values in the IDic? I have been trying to look for this for hours now. What I am doing is that I am using IDic to store the results for an XML function, but for the life of me do not know how to iterate Idic to retrieve the values I want.0 -
You know what, I found the answer. I was wondering why there was the Dotnet subtype SortedDictionary, and SortedDictionary+Enumerator.
Name DataType Subtype Length XPathNavigator DotNet System.Xml.XPath.XPathNavigator.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' IDicEnum DotNet System.Collections.Generic.SortedDictionary`2+Enumerator.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' IDic DotNet System.Collections.Generic.SortedDictionary`2.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' TempStr Text 250 FileName := 'c:\temp\temp1.xml'; FileName := FileMgmt.UploadFileSilent(FileName); IF NOT EXISTS(FileName) THEN EXIT; f.OPEN(FileName); f.TEXTMODE(TRUE); f.CREATEINSTREAM(FileInStream); XMLDoc.Load(FileInStream); RootNode := XMLDoc.DocumentElement; XPathNavigator := RootNode.CreateNavigator; IDic := XPathNavigator.GetNamespacesInScope(XMLNameSpaceScope.All); IDicEnum := IDic.GetEnumerator; WHILE IDicEnum.MoveNext DO BEGIN IDic := IDicEnum.Current; TempStr := IDic.ToString; MESSAGE(TempStr); END;
What the above code does is that it will get all name spaces in the xml file and store in Idic, and later using IdicEnum, it will iterate Idic and print all contents from IDic.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions