ObjectArray Method Call
Table of Contents
A ObjectArray Method Call is a Complex Method Call that returns a ObjectArray.
- See Methods for explanations of the basics and for Code examples and for the declaration of Method Calls.
See How to use Method Calls for general information on using Method Calls. - Go to the complete list of all Complex Method Calls
Code Example
The example exists of an Operation and a Form. In the operation the Entity Collection(s) and Dataview(s) are defined. The definitions of Lists and Method Call(s) for composing the data, based on input from the user, are also defined in the Forms.
Code example Operation
protected override IForm CreateStartupForm()
{
return new ObjectArrayMethodCallDemoFrm(this);
}
public IEntityCollection<ObjectArrayMethodCallDemoEntity> ObjectArray
{
get { return Property(() => new VolatileTable("object array").Select<ObjectArrayMethodCallDemoEntity>().All()); }
}
public IDataView<ObjectArrayMethodCallDemoEntity> ObjectArrayView
{
get { return Property(() => ObjectArray.ToView()); }
}
Explanation Code example Operation
- Lines 1-4: Definition of the Form (see code of the Form below).
- Lines 6-9: Definition of a Volatile Table. We fill this in the Form (below).
- Lines 11-14: Definition of the View, which is used to display the data in the Form.
- Lines 8 and 11: The necessary
ObjectArrayMethodCallDemoEntityis defined elsewhere. Type 'Volatile Table' in the Search box to read more about the working of the Volatile Table. - This
ObjectArrayMethodCallDemoEntityis also used in the Form below, on line 14.
Note: In this example, a Volatile Table is used. It is also possible to make a ObjectArray based on a Database Table.
Code example Form
public ObjectArrayMethodCallDemoFrm(ObjectArrayMethodCallDemoOp operation) : base(operation)
{
}
protected override IUIElement CreateGui()
{
return new VBox
{
new HBox
{
new GroupBox("example",2, alignV:AlignV.Top)
{
new DataGrid<ObjectArrayMethodCallDemoEntity>(Operation.ObjectArrayView, showColumnHeaders:false)
{
e => new DataGridColumn(e.Group) {Group = true},
e => e.Description
}
}
},
new HBox(alignH:AlignH.Fill)
{
new Button(GetObjectArray()),
EmptySpace.FillH,
new Button(Close())
}
};
}
private ObjectArray<StringList> ComposeObjectArray()
{
return Method<ObjectArray<StringList>>(() =>
{
var list = new StringList();
return new Body
{
list.Add("hello world"),
list.Add("pizza"),
list.Add("potato"),
list.Add("apple"),
list.Add("pear"),
new Return(new ObjectArray<StringList>(list, list, list, list, list))
};
});
}
private IMethodCall GetObjectArray()
{
return Method(() =>
{
var newArrayItem = Operation.ObjectArray.CreateItemReference();
var counter = new IntegerVariable(0);
return new Body
{
Operation.ObjectArray.DeleteAll(),
CalculateObjectArray().Foreach(objectItem => new Body
{
counter.Assign(counter+1),
objectItem.Foreach(listItem => new Body
{
newArrayItem.Assign(Operation.ObjectArray.New()),
newArrayItem.Group.Assign("array " + counter.ConvertToString()),
newArrayItem.Description.Assign(listItem)
})
})
};
})
.SetWorkDescription("get object array")
.SetImage(WikiImages.Directory)
.Call();
}
Warning:
All Method Calls and Complex Method Calls need a new Return(). They are like C# functions that need a return type.
The exception is an IMethodCall. In C# this is like a void method.
Explanation Code example Form
- Lines 6-28: The definition of the form.
- Line 14: The View, based on the Entity (see explanation 3 and 4 of the Operation), are passed to a DataGrid.
- Lines 31-46: This is a private property of the type
ObjectArray. In it, a StringList is composed (lines 38-44) and returned, converted to an Array in line 43. ThisObjectArraywas defined in the Operation as a Volatile Table. - Lines 48-73: This MethodCall, named GetObjectArray(), starts a new instance of
ObjectArrayon line 52. - Lines 57 and 60: There are two nested ForEach loops. This will result in a nested outcome (see below: Example of the result).
- Line 56 any previous data is deleted.
- Line 63: The title above each group (of the nested ForEach) is composed of the word List and the Counter (see lines 53 and 59).
- Line 64: Then the Array is filled by looping through the
ObjectArrayand assigning the value to the ArrayItems.
Example of the result
A form like the one defined above, could look like this.
When starting the application:

After clicking the button:
