MemberRelationshipService Class

Definition

Provides the base class for relating one member to another.

public abstract class MemberRelationshipService
Inheritance
MemberRelationshipService

Inherited Members

System.Object

Examples

The MemberRelationshipService simplifies retrieval of a property value from another location. A designer can access this service to dictate that one member is assigned the value of another. The code generator searches for such relationships when generating code, and if a relationship between two members is found the code generator, it emits code for the relationship rather than searching for the property value. Using the previous text assignment as an example, the following code example shows design time code used to establish a relationship.

object titleLabel, form;  
PropertyDescriptor titleLabelText = TypeDescriptor.GetProperties(titleLabel)["Text"];  
PropertyDescriptor formText = TypeDescriptor.GetProperties(form)["Text"];  
MemberRelationshipService ms = GetService(typeof(MemberRelationshipService);  
ms[titleLabel, titleLabelText] = new MemberRelationship(form, formText);  

Remarks

Designers serialize themselves to code through an engine that searches through the live property values of objects and generates those values as code. So, for example, the text of a button is generated in the following format.

this.okButton.Text = "OK";  

One of the limitations of this scheme is that it is difficult to retrieve a property from another location. For example, it is very difficult to emit code in the following format, because the only thing the code generator can rely on is the value in the property.

this.titleLabel.Text = this.Text;  

Constructors

MemberRelationshipService()

Initializes a new instance of the MemberRelationshipService class.

Properties

Item[MemberRelationship]

Establishes a relationship between a source and target object.

Item[Object, MemberDescriptor]

Establishes a relationship between a source and target object.

Methods

GetRelationship(MemberRelationship)

Gets a relationship to the given source relationship.

SetRelationship(MemberRelationship, MemberRelationship)

Creates a relationship between the source object and target relationship.

SupportsRelationship(MemberRelationship, MemberRelationship)

Gets a value indicating whether the given relationship is supported.