ZPT-Sharp  v1.0.0
Zope Page Templates for .NET
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties
CSF.Zpt.Rendering.NamedObjectWrapper Class Reference

Simple wrapper type which provides access to objects by System.String names. More...

Inheritance diagram for CSF.Zpt.Rendering.NamedObjectWrapper:
Collaboration diagram for CSF.Zpt.Rendering.NamedObjectWrapper:

Public Member Functions

virtual bool HandleTalesPath (string pathFragment, out object result, Rendering.IRenderingContext currentContext)
 Gets an System.Object based upon a TALES path fragment. More...
 
virtual void SetStringRepresentation (string name)
 Sets the string representation. More...
 
override string ToString ()
 Returns a System.String that represents the current CSF.Zpt.Rendering.NamedObjectWrapper. More...
 
 NamedObjectWrapper (IDictionary< string, object > objects=null)
 Initializes a new instance of the CSF.Zpt.Rendering.NamedObjectWrapper class. More...
 
- Public Member Functions inherited from CSF.Zpt.Tales.ITalesPathHandler
bool HandleTalesPath (string pathFragment, out object result, IRenderingContext currentContext)
 Gets an System.Object based upon a TALES path fragment. More...
 

Properties

object this[string key] [get, set]
 Gets or sets the item with the specified key. More...
 

Detailed Description

Simple wrapper type which provides access to objects by System.String names.

Constructor & Destructor Documentation

CSF.Zpt.Rendering.NamedObjectWrapper.NamedObjectWrapper ( IDictionary< string, object >  objects = null)
inline

Initializes a new instance of the CSF.Zpt.Rendering.NamedObjectWrapper class.

Parameters
objectsAn optional collection of the initial objects to load into the current instance.

Member Function Documentation

virtual bool CSF.Zpt.Rendering.NamedObjectWrapper.HandleTalesPath ( string  pathFragment,
out object  result,
Rendering.IRenderingContext  currentContext 
)
inlinevirtual

Gets an System.Object based upon a TALES path fragment.

This method should return a System.Object which represents the traversal of a single-level TALES path fragment, from the current instance. The value of that fragment is passed via the name pathFragment .

The precise meaning of 'traversal' is left to the implementation, but typical semantics will see an object return an associated object from an object graph.

In this simple example, the Employee class may return data from a related Person object, without exposing the Person object directly. This might be because (as shown in this example), the API of that Person object is more complex than desired, and so TALES should see a simplified version.

public class Employee : ITalesPathHandler
{
private Person _person;
public bool HandleTalesPath(string pathFragment, out object result, RenderingContext currentContext)
{
switch(pathFragment)
{
case: "name";
result = _person.Name;
return true;
case: "address";
result = _person.Address.FullAddress;
return true;
case: "gender":
result = _person.Gender.ToString();
return true;
default:
result = null;
return false;
}
}
}

Note that the return value does not need to be a primitive type. It may be a complex object, and the return value may also implement ITalesPathHandler if desired.

Returns
true if the path traversal was a success; false otherwise.
Parameters
pathFragmentThe path fragment.
resultExposes the result if the traversal was a success
currentContextGets the current rendering context.
virtual void CSF.Zpt.Rendering.NamedObjectWrapper.SetStringRepresentation ( string  name)
inlinevirtual

Sets the string representation.

Parameters
nameName.
override string CSF.Zpt.Rendering.NamedObjectWrapper.ToString ( )
inline

Returns a System.String that represents the current CSF.Zpt.Rendering.NamedObjectWrapper.

Returns
A System.String that represents the current CSF.Zpt.Rendering.NamedObjectWrapper.

Property Documentation

object CSF.Zpt.Rendering.NamedObjectWrapper.this[string key]
getset

Gets or sets the item with the specified key.

Parameters
keyKey.

The documentation for this class was generated from the following file: