Class Expando

Class that provides extensible properties and methods to an existing object when cast to dynamic. This dynamic object stores 'extra' properties in a dictionary or checks the actual properties of the instance passed via constructor.

This class can be subclassed to extend an existing type or you can pass in an instance to extend. Properties (both dynamic and strongly typed) can be accessed through an indexer.

This type allows you three ways to access its properties:

Directly: any explicitly declared properties are accessible Dynamic: dynamic cast allows access to dictionary and native properties/methods Dictionary: Any of the extended properties are accessible via IDictionary interface

public class Expando : DynamicObject

Class Members



This constructor just works off the internal dictionary and any public properties of this object.

Note you can subclass Expando.


String Dictionary that contains the extra dynamic values stored on this object/instance


Checks whether a property exists in the Property collection or as a property on the instance

public bool Contains(KeyValuePair<String,Object> item,     bool includeInstanceProperties)


Return both instance and dynamic names.

Important to return both so JSON serialization with Json.NET works.

public virtual IEnumerable GetDynamicMemberNames()


Returns and the properties of

public IEnumerable<KeyValuePair`2> GetProperties(bool includeInstanceProperties)


Try to retrieve a member by name first from instance properties followed by the collection entries.

public virtual bool TryGetMember(GetMemberBinder binder,     ref object result)


Dynamic invocation method. Currently allows only for Reflection based operation (no ability to add methods dynamically).

public virtual bool TryInvokeMember(InvokeMemberBinder binder,     Object[] args,     ref object result)


Property setter implementation tries to retrieve value from instance first then into this object

public virtual bool TrySetMember(SetMemberBinder binder,     object value)



Namespace: Westwind.Utilities
Assembly: westwind.utilities.dll

© West Wind Technologies, 2019 • Updated: 06/23/19
Comment or report problem with topic