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.

public bool Add(object item)

AddDictionaryItem

Adds an item to the dictionary by key and value.

public bool AddDictionaryItem(object key,     object value)

AddItem

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

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.

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

Creates a new instance of one of the list/collection's data type without actually adding it to the array, and returns the created object instance.

public object CreateItem()

CreateList

Creates an empty List of T.

public bool CreateList(string listTypeName)

FromEnumerable

Creates a copied array instance from an enumerable.

public void FromEnumerable(IEnumerable items)

GetInstanceTypename

Returns the .NET type name of the array/collection instance.

o.ComArray.GetInstanceTypename()

GetItemTypename

Returns the .NET typename for the array's items (if there are items). Otherwise value is empty.

o.ComArray.GetItemTypename()

Item

Returns an item by index or by key from an Array, List or Dictionary collection.

public object Item(object indexOrKey)

ItemRaw

Returns an item by index or key from a List or Dictionary collection without any type conversion for FoxPro.

public object ItemRaw(object indexOrKey)

Remove

Removes an item from the collection.

public bool Remove(object indexOrKey)

RemoveItem

Removes an item from the collection.

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-2024 • Updated: 10/21/22
Comment or report problem with topic