Class RegisteredObjects
Namespace: FastReport.Olap.Utils
Assembly: FastCube.Core.dll
Contains all registered report items such as objects, export filters, wizards.
public static class RegisteredObjects
Inheritance
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");
Remarks
Use this class to register own components, wizards, export filters or another items that need to be serialized to/from a report file.
Properties
Objects
Root object for all registered objects.
public static ObjectInfo Objects { get; }
Property Value
Methods
Add(Type, string)
Registers an object in the specified category.
public static void Add(Type obj, string category)
Parameters
obj Type
Type of object to register.
category string
Name of category to register in.
AddCategory(string, object, string)
Registers a category that may contain several report objects.
public static void AddCategory(string name, object image, string text)
Parameters
name string
Category name.
image object
Image for category button.
text string
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.
public static void AddCloud(Type obj, string text)
Parameters
obj Type
text string
AddExport(Type, string)
Registers a new export filter.
public static void AddExport(Type obj, string text)
Parameters
obj Type
Type of export filter.
text string
Text for export filter's menu item.
Examples
// register own export filter
RegisteredObjects.AddExport(typeof(MyExport), "My Export");
Remarks
The obj must be of FastReport.Olap.Export.ExportBase type.
AddExport(Type, string, string)
Registers a new export filter. FastReport.Olap.Utils.RegisteredObjects.AddExport(System.Type,System.String)
public static void AddExport(Type obj, string category, string text)
Parameters
obj Type
category string
text string
Exceptions
AddExportCategory(string, string)
Register Export category.
public static void AddExportCategory(string name, string text)
Parameters
name string
Category name.
text string
Category text.
AddFunction(MethodInfo, string)
Adds a new function into the specified category.
public static void AddFunction(MethodInfo function, string category)
Parameters
function MethodInfo
MethodInfo containing all necessary information about the function.
category string
The name of category to register the function in.
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");
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"
AddFunctionCategory(string, string)
Adds a new function category.
public static void AddFunctionCategory(string category, string text)
Parameters
category string
Short name of category.
text string
Display name of category.
Examples
This example shows how to register a new category:
RegisteredObjects.AddFunctionCategory("MyFuncs", "My Functions");
Remarks
Short name is used to reference the category in the subsequent FastReport.Olap.Utils.RegisteredObjects.AddFunction(System.Reflection.MethodInfo,System.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"
FindObject(Type)
Finds the registered object's info.
public static ObjectInfo FindObject(Type type)
Parameters
type Type
The type of object to find.
Returns
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.
public static bool IsTypeRegistered(Type obj)
Parameters
obj Type
Type to check.
Returns
true if such type is registered.