Table of Contents

Class DynamicDataObject

Namespace: Casewhere.SystemTypes
Assembly: Casewhere.SystemTypes.dll

Represents the data objects for working with Casewhere Runtime API.

public class DynamicDataObject : DynamicObject, IDynamicMetaObjectProvider

Inheritance

objectDynamicObjectDynamicDataObject

Implements

IDynamicMetaObjectProvider

Inherited Members

DynamicObject.TryGetMember(GetMemberBinder, out object), DynamicObject.TrySetMember(SetMemberBinder, object), DynamicObject.TryDeleteMember(DeleteMemberBinder), DynamicObject.TryInvokeMember(InvokeMemberBinder, object[], out object), DynamicObject.TryConvert(ConvertBinder, out object), DynamicObject.TryCreateInstance(CreateInstanceBinder, object[], out object), DynamicObject.TryInvoke(InvokeBinder, object[], out object), DynamicObject.TryBinaryOperation(BinaryOperationBinder, object, out object), DynamicObject.TryUnaryOperation(UnaryOperationBinder, out object), DynamicObject.TryGetIndex(GetIndexBinder, object[], out object), DynamicObject.TrySetIndex(SetIndexBinder, object[], object), DynamicObject.TryDeleteIndex(DeleteIndexBinder, object[]), DynamicObject.GetDynamicMemberNames(), DynamicObject.GetMetaObject(Expression), object.ToString(), object.Equals(object), object.Equals(object, object), object.ReferenceEquals(object, object), object.GetHashCode(), object.GetType(), object.MemberwiseClone()

Extension Methods

ObjectExtension.ConvertToBsonValue(object), EnumExtensions.DeepClone<DynamicDataObject>(DynamicDataObject)

Examples

var employee = ctx.Input; // employee is DynamicDataOject

Log.Info("Username: {Username}", employee["Username"]); // Username: "aadamowicz2o" 
Log.Info("Username: {Username}", employee.Get<string>("Username")); // Username: "aadamowicz2o"

Log.Info("Skills: {Skills}", employee["Skills"]); // Skills: ["java", "Fortran", "cpp"] 
Log.Info("Skills: {Skills}", employee.GetList<string>("Skills")); // Skills: ["java", "Fortran", "cpp"]

Log.Info("Departments: {Departments}", employee["SubDepartmentIds"]); // Departments: ["Department/6b9cd2ad-35d2-452e-9f60-a9c3006b21f3", "Department/24895ee7-5e4d-4130-ae2e-a9ca010731e0", "Department/2dd9ef92-efd5-419f-8448-a9b5009b426d"] 
Log.Info("Departments: {Departments}", employee.GetList<string>("SubDepartmentIds")); // Departments: ["Department/6b9cd2ad-35d2-452e-9f60-a9c3006b21f3", "Department/24895ee7-5e4d-4130-ae2e-a9ca010731e0", "Department/2dd9ef92-efd5-419f-8448-a9b5009b426d"]

dynamic emp = ctx.Input; // use as dynamic variable
Log.Info("Username: {Username}", emp.Username); // Username: "aadamowicz2o"

Constructors

DynamicDataObject()

Create instance of DynamicDataObject without provided data.

public DynamicDataObject()

DynamicDataObject(IDictionary<string, object>)

Create instance of DynamicDataObject with provided data with type is IDictionary<string, object>.

public DynamicDataObject(IDictionary<string, object> dict)

Parameters

dict IDictionary<string, object>

Provided data.

DynamicDataObject(object)

Create instance of DynamicDataObject with provided data with type is object.

public DynamicDataObject(object obj)

Parameters

obj object

Provided data.

Properties

HasData

Determines if the object has data properties or not.

public bool HasData { get; }

Property Value

bool

Properties

Actual data.

protected IDictionary<string, object> Properties { get; }

Property Value

IDictionary<string, object>

this[string]

Indexer returns value by property name.

public dynamic this[string key] { get; set; }

Property Value

dynamic

Methods

Add(string, object)

Add value with name.

public void Add(string property, object value)

Parameters

property string

The key name.

value object

The value.

FromObject(object)

Remove value with name if found. Otherwise, throw exception ArgumentNullException.

public static DynamicDataObject FromObject(object obj)

Parameters

obj object

The object value.

Returns

DynamicDataObject

DynamicDataObject with actual data if obj not null, otherwise, null.

Get<T>(string)

Get value by property name.

public T Get<T>(string key)

Parameters

key string

Property name.

Returns

T

Property value.

Type Parameters

T

Type of the object property.

Get(string)

Get value by property name.

public dynamic Get(string key)

Parameters

key string

Property name.

Returns

dynamic

Property value.

GetDynamicMemberNames()

Get the field names.

public override IEnumerable<string> GetDynamicMemberNames()

Returns

IEnumerable<string>

IEnumerable of field names

GetGuid(string)

Get value by property name.

public Guid GetGuid(string key)

Parameters

key string

Property name.

Returns

Guid

Property value with type is Guid.

Exceptions

InvalidCastException

if the property data is not IEnumerable

GetList<T>(string)

Get list of values by property name.

public IList<T> GetList<T>(string key)

Parameters

key string

Property name.

Returns

IList<T>

Property values.

Type Parameters

T

Type of the object property.

Exceptions

InvalidCastException

if the property data is not IEnumerable

GetList(string)

Get list of values by property name.

public IList<dynamic> GetList(string key)

Parameters

key string

Property name.

Returns

IList<dynamic>

Property values.

Exceptions

InvalidCastException

if the property data is not IEnumerable

GetProperties()

Get actual data of DynamicDataObject.

public IDictionary<string, object> GetProperties()

Returns

IDictionary<string, object>

The data.

Has(string)

Determines if a property has data or not.

public bool Has(string propertyName)

Parameters

propertyName string

The property name

Returns

bool

True if a property has data; otherwise, False.

HasKey(string)

Determines if a property has key or not.

public bool HasKey(string keyName)

Parameters

keyName string

The key name

Returns

bool

True if have key; otherwise, False.

Remove(string)

Remove value with name if found. Otherwise, throw exception ArgumentNullException.

public void Remove(string property)

Parameters

property string

The key name.

ToExpandoObject()

public ExpandoObject ToExpandoObject()

Returns

ExpandoObject

ToJObject()

Converts to JObject.

public JObject ToJObject()

Returns

JObject

Value as JObject

ToString()

Converts to string.

public override string ToString()

Returns

string

Value as string

TryConvert(ConvertBinder, out object)

Try convert the

public override bool TryConvert(ConvertBinder binder, out object result)

Parameters

binder ConvertBinder

Set member operation.

result object

The converted value.

Returns

bool

True if success convert, otherwise, false.

TryGetMember(GetMemberBinder, out object)

Get the value of object.

public override bool TryGetMember(GetMemberBinder binder, out object result)

Parameters

binder GetMemberBinder

Get member operation.

result object

The value if found, otherwise, null.

Returns

bool

True if found, otherwise, false.

TrySetMember(SetMemberBinder, object)

Set the value of object. Override if the key is existed.

public override bool TrySetMember(SetMemberBinder binder, object value)

Parameters

binder SetMemberBinder

Set member operation.

value object

The value.

Returns

bool

True