New to Telerik Reporting? Start a free 30-day trial

Used to specify the usage and the design time description of the aggregate function. This class cannot be inherited.

Definition

Namespace:Telerik.Reporting.Expressions

Assembly:Telerik.Reporting.dll

Syntax:

C#
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public sealed class AggregateFunctionAttribute : Attribute

Inheritance: objectAttributeAggregateFunctionAttribute

Example:

This example shows the usage of the attribute.

cs
[AggregateFunction(Description = "Concatenation aggregate. Output: (value1, value2, ...)", Name = "Concatenate")]
class ConcatenateAggregate : IAggregateFunction
{
    string result;

    public void Accumulate(object[] values)
    {
        // The aggregate function expects one parameter
        object value = values[0];

        // null values are not aggregated
        if (null == value)
        {
            return;
        }

        // The actual accumulation
        if (this.result.Length > 0)
        {
            result += ", ";
        }
        this.result += value.ToString();
    }

    public object GetValue()
    {
        return string.Format("({0})", this.result);
    }

    public void Init()
    {
        // Add aggregate function initialization code here if needed
        this.result = string.Empty;
    }

    public void Merge(IAggregateFunction aggregateFunction)
    {
        ConcatenateAggregate aggregate = (ConcatenateAggregate)aggregateFunction;

        if (aggregate.result.Length > 0)
        {
            if (this.result.Length > 0)
            {
                result += ", ";
            }
            this.result += aggregate.result;
        }
    }
}
vb
  _ Class ConcatenateAggregate Implements IAggregateFunction Private result As String
Public Sub Accumulate(ByVal values As Object()) Implements IAggregateFunction.Accumulate

    ' The aggregate function expects one parameter

    Dim value As Object = values(0)


    ' null values are not aggregated

    If value Is Nothing Then
        Return
    End If


    ' The actual accumulation

    If Me.result.Length > 0 Then
        result += ", "
    End If
    Me.result += value.ToString()
End Sub
Public Function GetValue() As Object Implements IAggregateFunction.GetValue
    Return String.Format("({0})", Me.result)
End Function
Public Sub Init() Implements IAggregateFunction.Init

    ' Add aggregate function initialization code here if needed

    Me.result = String.Empty
End Sub
Public Sub Merge(ByVal aggregateFunction As IAggregateFunction) Implements IAggregateFunction.Merge
    Dim aggregate As ConcatenateAggregate = DirectCast(aggregateFunction, ConcatenateAggregate)

    If aggregate.result.Length > 0 Then
        If Me.result.Length > 0 Then
            result += ", "
        End If
        Me.result += aggregate.result
    End If
End Sub End Class

Constructors

Initializes a new instance of the AggregateFunctionAttribute class.

C#
public AggregateFunctionAttribute()

Fields

Returns the default instance of the attribute with all its properties set to default values.

C#
public static readonly AggregateFunctionAttribute Default

Properties

Gets the description of the aggregate function displayed in the expression builder.

C#
public string Description { get; set; }

Gets a value indicating whether the aggregate should be shown at design time. Default value is true.

C#
public bool IsVisible { get; set; }

Name

string

Gets the name of the aggregate function as it should be used in the expressions.

C#
public string Name { get; set; }

Gets or sets the return type of the aggregate function as it should be used in the expressions.

C#
public Type ReturnType { get; set; }

Methods

Indicates whether this attribute instance and a specified object are equal.

C#
public override bool Equals(object obj)
Parameters:objobject

Another object to compare to.

Returns:

bool

true if obj is equal to this instance; otherwise, false.

Overrides: Attribute.Equals(object)

Returns the hash code for this attribute instance.

C#
public override int GetHashCode()
Returns:

int

A 32-bit signed integer hash code.

Overrides: Attribute.GetHashCode()

Determines if this attribute is the default.

C#
public override bool IsDefaultAttribute()
Returns:

bool

true if the attribute is the default value for this attribute class; otherwise, false.

Overrides: Attribute.IsDefaultAttribute()