Class ComArray

COM Wrapper for Arrays, IList and IDictionary collections that are not directly or easily accessible in FoxPro. Provides members like Count, Item() for index or key retrieval, AddItem(), AddDictionaryItem(), RemoveItem(), Clear() to provide common collection operations more naturally in FoxPro abstracted for the different types of collections available in .NET (Arrays, Lists, Hash tables, Dictionaries).

Internally stores an instance of the collection so the collection is never actually passed to FoxPro. Instead this class acts as a proxy to the collection which is stored in the .Instance property.

This instance allows Visual FoxPro to manipulate the collection by directly accessing array, list or dictionary values by index or key (depending on list or collection), adding, removing and clearing items, creating array, list and dictionary instances and assigning and picking up these values from existing objects.

This class is also internally used to capture collections that are returned from method calls or Properties via InvokeMethod() and GetProperty() and can be used to pass collections to .NET which otherwise would not be possible over COM.

System.Object
  Westwind.WebConnection.ComArray
public class ComArray : object

Class Members

MemberDescription

Constructor

Default constructor

Add

Adds an item to the internal list or collection/dictionary.

The list or collection has to exist or an exception is thrown.

public bool Add(object item)

AddDictionaryItem

Adds an item to the dictionary by key and value.

The list or collection has to exist or an exception is thrown.

public bool AddDictionaryItem(object key,     object value)

AddItem

Adds an item to the internal list, array or single item collection.

The list or collection has to exist or an exception is thrown.

public bool AddItem(object item)

AssignFrom

Assigns a .NET collect to this ComArray Instance. Has to be passed as a base instance (ie. parent instance of the array) and the name of the array because once the array hits VFP code it's already been converted into a VFP array so only internal reflection will allow getting the actual reference into ComArray.

public bool AssignFrom(object baseInstance,     string arrayPropertyName)

AssignTo

Assigns this ComArray's array instance to the specified property

public bool AssignTo(object baseInstance,     string arrayPropertyName)

Clear

Clears out the collection's content.

public bool Clear()

CreateArray

Creates a new array instance with size number of items pre-set. Elements are unassigned but array is dimensioned. Use 0 for an empty array.

Use SetItem() to assign values to each array element

public bool CreateArray(string arrayTypeName,     int size)

CreateDictionary

Creates an empty Dictionary with specified key value types

public bool CreateDictionary(string keyTypeName,     string valueTypeName)

CreateItem

public object CreateItem()

CreateList

Creates an empty List of T.

public bool CreateList(string listTypeName)

FromEnumerable

public void FromEnumerable(IEnumerable items)

Item

public object Item(object indexOrKey)

Remove

Removes an item from the collection.

Depending on the item is a List style item (Array, List, HashSet, simple Collections) or a Key Value type collection (Dictionary or custom key value collections like StringCollection), you specify an index (lists), value (Hash tables/collections), or a key (Dictionary).

public bool Remove(object indexOrKey)

RemoveItem

Removes an item from the collection.

Depending on the item is a List style item (Array, List, HashSet, simple Collections) or a Key Value type collection (Dictionary or custom key value collections like StringCollection), you specify an index (lists), value (Hash tables/collections), or a key (Dictionary).

public bool RemoveItem(object indexOrKey)

SetItem

Updates a value to an existing collection or list item by int index for lists, or a key or value for dictionaries/collections

public bool SetItem(object indexOrKey,     object value)

Count

Returns the length of the .NET array contained in Instance

Instance

The actual array instance returned as an object. This instance is set and passed to and from .NET calls made with InvokeMethod and explicit property assignments with Set/GetProperty.

Requirements

Namespace: Westwind.WebConnection
Assembly: wwdotnetbridge.dll

See also:

Array, List and Dictionary Access with ComArray

© West Wind Technologies, 1996-2022 • Updated: 10/21/22
Comment or report problem with topic