basic functionality for working with arrays of objects metalowych
DetailArray supports basic functionality for working with arrays metalowych close
- Support links to hat (aggregator).
- Support for collections:
- add (AddObject, AddRange),
- insert (Insert),
- delete (Remove RemoveByIndex, RemoveByKey),
- clear (Clear),
- install/capture values (GetByKey, SetByKey),
- move (Move)
- the number of objects (Count),
- iterates through the objects in the foreach construct.
- Support the ordering (the order in which lie data objects).
Among the objects in the array datalow, calculate some aggregate function (sum, max, min, mean, anything random), it is necessary in the class inherited from
DetailArray, to define a function without parameters that returns a value. Further to this function, you must attribute the attribute
AggregationFunction. Parameters are: name of the property for which this aggregation function, and a format string (
String.Format), according to which the value is displayed to the user.
AggregationFunctiontaken to process the following: if you specify a property name, the value of the aggregation function is indicated directly next to the values of data objects (e.g., bottom of the table in the corresponding column) and type a function’s return value must be the same or implicitly castable to the property type. If you specify a format string then the value is displayed separately in this format.
The objects in the array of datalow can be ordered (it is ordered but not sorted), i.e., be placed in any strict order.
In order to introduce a regularization, it is necessary to metalowy class of data to enter an integer (
System.Int32) property with assigned attribute
get type DetailArray its name
To get the type of detail, having the type of aggregator and the name DetailArray, it is necessary to use the method of Information.GetItemType.
public static System.Type ICSSoft.STORMNET.Information.GetItemType ( System.Type AgregatorType, string DetailPropertyName )
AgregatorType is the class type of the aggregator, and
DetailPropertyName is the name of the list of datalow whose type to get.
The method returns an object of type
System.Type containing a description of the type of detail.
Writing LINQ queries to the already made list DetailArrayOf…
To write a LINQ query to detalam, you must first bring them to the required type (because DetailArrayOf… does not support the interface
IEnumerable, directly to him LINQ methods (such as
ToList, etc.) will not apply).
Suppose there is a class
Aggregator having metalowy class
Det, then the construction below will give
ошибку, because it is necessary to specify the type of objects which will populate a new list:
Aggregator aggr = new Aggregator(); aggr.DetailArrayOfDet.ToList();
If you specify a type, then
ошибка changes to
Невозможно lead type DetailArrayOfDet type IEnumerable<<Det>:
Aggregator aggr = new Aggregator(); aggr.DetailArrayOfDet.ToList<Det>();
Правильным способом is:
Aggregator aggr = new Aggregator(); aggr.DetailArrayOfDet.Cast<Det>.ToList();