Questions tagged [dynamicobject]

A Microsoft .NET Framework (version 4+) base class for specifying dynamic behavior at run time.

The DynamicObject class enables you to define which operations can be performed on dynamic objects and how to perform those operations. The DynamicObject class enables you to override operations like getting or setting a member, calling a method, or performing any binary, unary, or type conversion operation.

Inheritance Hierarchy

System.Object   
  System.Dynamic.DynamicObject

Reference: https://msdn.microsoft.com/en-us/library/system.dynamic.dynamicobject%28v=vs.110%29.aspx

171 questions
9
votes
2 answers

C# DynamicObject dynamic properties

Assuming I cannot use an ExpandoObject and have to roll my own like so :- class MyObject : DynamicObject { dictionary _properties = dictionary(); public override bool TryGetMember(GetMemberBinder binder, out…
mfc
  • 3,018
  • 5
  • 31
  • 43
7
votes
2 answers

Casting Dynamic Object and Passing Into UnitOfWork and Repository Pattern. Throws Exception

This is a very specific problem. Not quite sure how to even word it. Basically I am implementing the unit of work and repository pattern, I have a dynamic object that I convert to an int, but if I use var it will throw an exception when trying to…
6
votes
1 answer

How to serialize dynamic object to xml c#

I have a object {System.Collections.Generic.List} that contains 1000 object {DynamicData} inside of it, each one with 4 keys and values and one more List with 2 keys and values inside. I need to serialize this object into a XML File, i tried…
Lucio Zenir
  • 365
  • 2
  • 8
  • 18
6
votes
2 answers

C# How to serialize (JSON, XML) normal properties on a class that inherits from DynamicObject

I am trying to serialize an instance of a class that inherits from DynamicObject. I've had no trouble getting the dynamic properties to serialize (not demonstrated here for brevity), but "normal" properties don't seem to make the trip. I experience…
DJ Grossman
  • 600
  • 6
  • 17
5
votes
1 answer

DynamicObject and TrySetMember performance vs ExpandoObject performance

I'm using a custom implementation of a DynamicObject which works perfectly for my application, other than the fact that I'm running into some performance issues. Some performance overhead is to be expected with dynamics, but I'm seeing significant…
bjquinn
  • 53
  • 1
  • 4
5
votes
0 answers

Does ExpandoObject in c# has instance accessor like this?

consider I have this simple c# code: dynamic obj = new ExpandoObject(); obj.FirstName = "John"; obj.LastName = "Doe"; I want to add method which will return full name, John Doe in this case. I know the following line will work, but not sure if it…
Arkadi
  • 1,153
  • 1
  • 14
  • 35
5
votes
1 answer

Count objects within dynamic anonymous object (C#)

I have a dynamic object (it's actually json) that I pass into my MVC WebApi controller. The json object contains multiple lists within an anonymous object that are submitted to the controller from another application via…
Alex
  • 75,813
  • 86
  • 255
  • 348
4
votes
1 answer

C# 4.0 Dynamic Object with ASP.NET DataBinding

I am trying to display in an ASP.NET GridView a property of a bound object that has been dynamically created using a dynamic object. In my example, DynamicProperties.FullName is dynamic. My client code is:
Omid B.
  • 356
  • 4
  • 13
4
votes
1 answer

Serialize instance of a class deriving from DynamicObject class

I have a class that derives from DynamicObject class. On calling JsonConvert.SertializeObject, none of the dynamic properties are serialized. Class is defined as, public class Component : DynamicObject { // The inner…
Usman Khan
  • 139
  • 2
  • 12
4
votes
1 answer

(De)Serialize DynamicObject with Jil?

I have a problem to (de)serialize DynamicObject with other json library that is not Newtownsoft.Json. (Jil, NetJSON, ServiceStack.Text...) This is my expandable object class: public class ExpandableObject : DynamicObject { private readonly…
Refactor-Man
  • 443
  • 8
  • 17
4
votes
1 answer

How to use Parallel.ForEach method with Dynamic objects

I have used Parallel.ForEach feature beafore to process multiple clients simultaneously like this: Clients objClient = new Clients(); List objClientList = Clients.GetClientList(); Parallel.ForEach(objClientList, list => { …
Learner
  • 3,904
  • 6
  • 29
  • 44
4
votes
2 answers

IronPython calls TryGetMember instead of TryInvokeMember

i'm trying to hand over a Dynamic object to Ironpython, but it seems Ironpython is not calling TryInvokeMember. Instead it calls TryGetMember and gives an Error that it cant call the result. I have tried it with IronPython 2.7 and…
lcrazyl
  • 63
  • 6
4
votes
1 answer

why can't I use GetType().GetProperty() on objects that inherit from DynamicObject?

I'm trying to retrive fields or properties from a dynamic class using reflection, but when I call the dynamic object using Getfield or GetProperty it can never find the field and none of the dynamic object.Try* methods are entered. Not sure why this…
3
votes
2 answers

Dynamic model with Telerik ASP MVC

Has anyone found a way to dynamically create a grid using ExpandoObject, DynamicObject or Reflection.Emit and at the same time allow CRUD operations? I was able to use Reflection.Emit to dynamically create my grid columns and display data, but once…
3
votes
1 answer

How to deserialize dictionary with hierarchical keys to dynamic object?

I'm receiving data in dictionary form and would like to deserialize it into a dynamic object. The twist is the dictionary keys express a hierarchical object. A second twist is some of the keys express an array and/or dictionary property. For…
Rick
  • 5,029
  • 2
  • 33
  • 34
1
2
3
11 12