Class RegisteredObjects
Contains all registered report items such as objects, export filters, wizards.
Inheritance
Namespace: FastReport.Olap.Utils
Assembly: FastReport.Olap.dll
Syntax
public static class RegisteredObjects
Remarks
Use this class to register own components, wizards, export filters or another items that need to be serialized to/from a report file.
Examples
// register own wizard
RegisteredObjects.AddWizard(typeof(MyWizard), myWizBmp, "My Wizard", true);
// register own export filter
RegisteredObjects.AddExport(typeof(MyExport), "My Export");
// register own report object
RegisteredObjects.Add(typeof(MyObject), "ReportPage", myObjBmp, "My Object");
Properties
Objects
Root object for all registered objects.
Declaration
public static ObjectInfo Objects { get; }
Property Value
| Type | Description |
|---|---|
| ObjectInfo |
Methods
Add(Type, String)
Registers an object in the specified category.
Declaration
public static void Add(Type obj, string category)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | obj | Type of object to register. |
| System.String | category | Name of category to register in. |
AddCategory(String, Bitmap, String)
Registers a category that may contain several report objects.
Declaration
public static void AddCategory(string name, Bitmap image, string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Category name. |
| System.Drawing.Bitmap | image | Image for category button. |
| System.String | text | Text for category button. |
Remarks
Category is a button on the "Objects" toolbar that shows context menu with nested items when you click it. Consider using categories if you register several report objects. It can save space on the "Objects" toolbar. For example, FastReport registers one category called "Shapes" that contains the LineObject and different types of ShapeObject.
When register an object inside a category, you must specify the full category name in the category parameter of the Add method.
AddCloud(Type, String)
Registers a new clouds.
Declaration
public static void AddCloud(Type obj, string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | obj | |
| System.String | text |
AddExport(Type, String)
Registers a new export filter.
Declaration
public static void AddExport(Type obj, string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | obj | Type of export filter. |
| System.String | text | Text for export filter's menu item. |
Remarks
The obj must be of ExportBase type.
Examples
// register own export filter
RegisteredObjects.AddExport(typeof(MyExport), "My Export");
AddExport(Type, String, String)
Declaration
public static void AddExport(Type obj, string category, string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | obj | |
| System.String | category | |
| System.String | text |
AddExportCategory(String, String)
Register Export category.
Declaration
public static void AddExportCategory(string name, string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Category name. |
| System.String | text | Category text. |
AddFunction(MethodInfo, String)
Adds a new function into the specified category.
Declaration
public static void AddFunction(MethodInfo function, string category)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Reflection.MethodInfo | function | MethodInfo containing all necessary information about the function. |
| System.String | category | The name of category to register the function in. |
Remarks
Your function must be a static, public method of a public class.
The following standard categories are registered by default:
- "Math"
- "Text"
- "DateTime"
- "Formatting"
- "Conversion"
- "ProgramFlow"
FastReport uses XML comments to display your function's description. To generate XML comments, enable it in your project's properties ("Project|Properties..." menu, "Build" tab, enable the "XML documentation file" checkbox).
Examples
The following example shows how to register own functions:
public static class MyFunctions
{
/// <summary>
/// Converts a specified string to uppercase.
/// </summary>
/// <param name="s">The string to convert.</param>
/// <returns>A string in uppercase.</returns>
public static string MyUpperCase(string s)
{
return s == null ? "" : s.ToUpper();
}
/// <summary>
/// Returns the larger of two 32-bit signed integers.
/// </summary>
/// <param name="val1">The first of two values to compare.</param>
/// <param name="val2">The second of two values to compare.</param>
/// <returns>Parameter val1 or val2, whichever is larger.</returns>
public static int MyMaximum(int val1, int val2)
{
return Math.Max(val1, val2);
}
/// <summary>
/// Returns the larger of two 64-bit signed integers.
/// </summary>
/// <param name="val1">The first of two values to compare.</param>
/// <param name="val2">The second of two values to compare.</param>
/// <returns>Parameter val1 or val2, whichever is larger.</returns>
public static long MyMaximum(long val1, long val2)
{
return Math.Max(val1, val2);
}
}
// register a category
RegisteredObjects.AddFunctionCategory("MyFuncs", "My Functions");
// obtain MethodInfo for our functions
Type myType = typeof(MyFunctions);
MethodInfo myUpperCaseFunc = myType.GetMethod("MyUpperCase");
MethodInfo myMaximumIntFunc = myType.GetMethod("MyMaximum", new Type[] { typeof(int), typeof(int) });
MethodInfo myMaximumLongFunc = myType.GetMethod("MyMaximum", new Type[] { typeof(long), typeof(long) });
// register simple function
RegisteredObjects.AddFunction(myUpperCaseFunc, "MyFuncs");
// register overridden functions
RegisteredObjects.AddFunction(myMaximumIntFunc, "MyFuncs,MyMaximum");
RegisteredObjects.AddFunction(myMaximumLongFunc, "MyFuncs,MyMaximum");
AddFunctionCategory(String, String)
Adds a new function category.
Declaration
public static void AddFunctionCategory(string category, string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | category | Short name of category. |
| System.String | text | Display name of category. |
Remarks
Short name is used to reference the category in the subsequent AddFunction(MethodInfo, String) method call. It may be any value, for example, "MyFuncs". Display name of category is displayed in the "Data" window. In may be, for example, "My Functions".
The following standard categories are registered by default:
- "Math"
- "Text"
- "DateTime"
- "Formatting"
- "Conversion"
- "ProgramFlow"
Examples
This example shows how to register a new category:
RegisteredObjects.AddFunctionCategory("MyFuncs", "My Functions");
FindObject(Type)
Finds the registered object's info.
Declaration
public static ObjectInfo FindObject(Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | type | The type of object to find. |
Returns
| Type | Description |
|---|---|
| ObjectInfo | The object's info. |
Remarks
This method can be used to disable some objects, for example:
RegisteredObjects.FindObject(typeof(PDFExport)).Enabled = false;
IsTypeRegistered(Type)
Checks whether the specified type is registered already.
Declaration
public static bool IsTypeRegistered(Type obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | obj | Type to check. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if such type is registered. |