C# Класс Westwind.Utilities.Expando

Наследование: System.Dynamic.DynamicObject, IDynamicMetaObjectProvider
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
Properties PropertyBag

Private Properties

Свойство Тип Описание

Открытые методы

Метод Описание
Contains ( object>.KeyValuePair item, bool includeInstanceProperties = false ) : bool

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

Expando ( ) : System

This constructor just works off the internal dictionary and any public properties of this object. Note you can subclass Expando.

Expando ( object>.IDictionary dict ) : System

Create an Expando from a dictionary

Expando ( object instance ) : System

Allows passing in an existing instance variable to 'extend'.

You can pass in null here if you don't want to check native properties and only check the Dictionary!

GetDynamicMemberNames ( ) : IEnumerable

Return both instance and dynamic names. Important to return both so JSON serialization with Json.NET works.

GetProperties ( bool includeInstanceProperties = false ) : object>>.IEnumerable

Returns and the properties of

TryGetMember ( GetMemberBinder binder, object &result ) : bool

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

TryInvokeMember ( InvokeMemberBinder binder, object args, object &result ) : bool

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

TrySetMember ( SetMemberBinder binder, object value ) : bool

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

this ( string key ) : object

Convenience method that provides a string Indexer to the Properties collection AND the strongly typed properties of the object by name. // dynamic exp["Address"] = "112 nowhere lane"; // strong var name = exp["StronglyTypedProperty"] as string;

The getter checks the Properties dictionary first then looks in PropertyInfo for properties. The setter checks the instance properties before checking the Properties dictionary.

Защищенные методы

Метод Описание
GetProperty ( object instance, string name, object &result ) : bool

Reflection Helper method to retrieve a property

Initialize ( object instance ) : void
InvokeMethod ( object instance, string name, object args, object &result ) : bool

Reflection helper method to invoke a method

SetProperty ( object instance, string name, object value ) : bool

Reflection helper method to set a property value

Описание методов

Contains() публичный Метод

Checks whether a property exists in the Property collection or as a property on the instance
public Contains ( object>.KeyValuePair item, bool includeInstanceProperties = false ) : bool
item object>.KeyValuePair
includeInstanceProperties bool
Результат bool

Expando() публичный Метод

This constructor just works off the internal dictionary and any public properties of this object. Note you can subclass Expando.
public Expando ( ) : System
Результат System

Expando() публичный Метод

Create an Expando from a dictionary
public Expando ( object>.IDictionary dict ) : System
dict object>.IDictionary
Результат System

Expando() публичный Метод

Allows passing in an existing instance variable to 'extend'.
You can pass in null here if you don't want to check native properties and only check the Dictionary!
public Expando ( object instance ) : System
instance object
Результат System

GetDynamicMemberNames() публичный Метод

Return both instance and dynamic names. Important to return both so JSON serialization with Json.NET works.
public GetDynamicMemberNames ( ) : IEnumerable
Результат IEnumerable

GetProperties() публичный Метод

Returns and the properties of
public GetProperties ( bool includeInstanceProperties = false ) : object>>.IEnumerable
includeInstanceProperties bool
Результат object>>.IEnumerable

GetProperty() защищенный Метод

Reflection Helper method to retrieve a property
protected GetProperty ( object instance, string name, object &result ) : bool
instance object
name string
result object
Результат bool

Initialize() защищенный Метод

protected Initialize ( object instance ) : void
instance object
Результат void

InvokeMethod() защищенный Метод

Reflection helper method to invoke a method
protected InvokeMethod ( object instance, string name, object args, object &result ) : bool
instance object
name string
args object
result object
Результат bool

SetProperty() защищенный Метод

Reflection helper method to set a property value
protected SetProperty ( object instance, string name, object value ) : bool
instance object
name string
value object
Результат bool

TryGetMember() публичный Метод

Try to retrieve a member by name first from instance properties followed by the collection entries.
public TryGetMember ( GetMemberBinder binder, object &result ) : bool
binder System.Dynamic.GetMemberBinder
result object
Результат bool

TryInvokeMember() публичный Метод

Dynamic invocation method. Currently allows only for Reflection based operation (no ability to add methods dynamically).
public TryInvokeMember ( InvokeMemberBinder binder, object args, object &result ) : bool
binder System.Dynamic.InvokeMemberBinder
args object
result object
Результат bool

TrySetMember() публичный Метод

Property setter implementation tries to retrieve value from instance first then into this object
public TrySetMember ( SetMemberBinder binder, object value ) : bool
binder System.Dynamic.SetMemberBinder
value object
Результат bool

this() публичный Метод

Convenience method that provides a string Indexer to the Properties collection AND the strongly typed properties of the object by name. // dynamic exp["Address"] = "112 nowhere lane"; // strong var name = exp["StronglyTypedProperty"] as string;
The getter checks the Properties dictionary first then looks in PropertyInfo for properties. The setter checks the instance properties before checking the Properties dictionary.
public this ( string key ) : object
key string
Результат object

Описание свойств

Properties публичное свойство

String Dictionary that contains the extra dynamic values stored on this object/instance
Using PropertyBag to support XML Serialization of the dictionary
public PropertyBag Properties
Результат PropertyBag