DataAttribute Class
Assembly: CodeEffects.Rule.Common.dll
Namespace: CodeEffects.Rule.Common.Attributes
Summary
Defines a single reusable Dynamic Menu Data Source on a source object level.
Syntax
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = true)]
public class DataAttribute : System.Attribute
Constructors
DataAttribute(string name, Type type, string methodName)
Initializes a new instance of the DataAttribute class with the type that declares the data source method.
Parameters
- name (
System.String) - The unique name of the data source.
- type (
System.Type) - The type that declares the data source method.
- methodName (
System.String) - The name of the data source method.
DataAttribute(string name, string declaringTypeOrAliasName, string methodName)
Initializes a new instance of the DataAttribute class with the assembly-qualified name or the alias name of the type that declares the data source method.
Parameters
- name (
System.String) - The unique name of the data source.
- declaringTypeOrAliasName (
System.String) - The assembly-qualified name or alias name of the type that declares the data source method.
- methodName (
System.String) - The name of the data source method.
DataAttribute(string name, string methodName)
Deprecated. This constructor is obsolete and will be removed in future versions. Use DataAttribute(string name, Type type, string methodName) or DataAttribute(string name, string declaringTypeOrAliasName, string methodName) instead.
Initializes a new instance of the DataAttribute class. The attribute created this way names no declaring type.
Parameters
- name (
System.String) - The unique name of the data source.
- methodName (
System.String) - The name of the data source method.
DataAttribute(string name, string assemblyName, string declaringTypeName, string methodName)
Deprecated. This constructor is obsolete and will be removed in a future major version. Use DataAttribute(string name, string declaringTypeOrAliasName, string methodName) instead, passing the AssemblyQualifiedName of the type that declares the data source method.
Initializes a new instance of the DataAttribute class.
Parameters
- name (
System.String) - The unique name of the data source.
- assemblyName (
System.String) - The name of the assembly that declares the type.
- declaringTypeName (
System.String) - The name of the type that declares the data source method.
- methodName (
System.String) - The name of the data source method.
Properties
Assembly
Type: System.String
Deprecated. This property is obsolete and will be removed in future versions. Use TypeOrAliasName and set it to the AssemblyQualifiedName of the type that declares the data source method.
Always returns null.
Method
Type: System.String
Gets the name of the method that provides the menu data source. This must be a public parameterless method that returns an ICollection<DataSourceItem>.
Name
Type: System.String
Gets the unique name of the data source, which can be used to distinguish this menu data source from all other menu data sources within the same source object. You can think of this property as a data source identifier that is unique only within the current source object. The uniqueness of each name must be ensured by the developer; Rule Editor does not enforce it. This property is required.
Type
Type: System.Type
Gets the type that declares the data source method. This property is null if the attribute was created with a type name; then TypeOrAliasName is set instead.
TypeName
Type: System.String
Deprecated. This property is obsolete and will be removed in future versions. Use TypeOrAliasName instead.
Returns the value of TypeOrAliasName.
TypeOrAliasName
Type: System.String
Gets the assembly-qualified name or alias name of the type that declares the data source method. This property is null if the attribute was created with a System.Type; then Type is set instead. You can obtain this name by executing typeof(ClassName).AssemblyQualifiedName.
Example
using System.Collections.Generic;
using CodeEffects.Rule.Common.Attributes;
using CodeEffects.Rule.Editor.Client;
namespace TestLibrary
{
[Data("Schools", typeof(Lookups), nameof(Lookups.GetSchools))]
public class Student
{
[Field(DataSourceName = "Schools")]
public int SchoolID { get; set; }
}
public class Lookups
{
public static ICollection<DataSourceItem> GetSchools()
{
return new List<DataSourceItem>
{
new DataSourceItem(1, "Central High"),
new DataSourceItem(2, "Lincoln Academy")
};
}
}
}