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
0
votes
4 answers

Cannot convert from custom object to object or dynamic

I have a List which I would like to populate with different types of objects, trying to do it with object\dynamic, but it doesn't, even when casting. using asp.net core. See my code: public Dictionary getEmployees(); //This method…
Guy E
  • 1,775
  • 2
  • 27
  • 55
0
votes
2 answers

C# Instantiate a Class from String name

Having multiple classes doing many things, I am obliged to instantiate one of them, populate some properties and call a method. A sample would be having the below methods e.g. public class Method100Response201 { public string…
Nick
  • 483
  • 1
  • 6
  • 15
0
votes
2 answers

WPF c# DynamicObject. how to enforce type checking on the added properties?

I define a DynamicObject. I have created a list of DynamicObjects with the same structure and link them to a WPF GridView. I allow editing of some of the properties via the grid. As the DynamicObjects present the property data as objects, how can I…
Lance
  • 251
  • 5
  • 13
0
votes
2 answers

How can set a property using the same name without changing existing value

Using JavaScript, how can I set property of an object that already has property with the same name? For example, what i want to output is: var obj = { name: "foo" }; obj[name] = "baz"; Normal output is: console.log(obj) => {name:baz}. I want…
Mert
  • 474
  • 2
  • 8
  • 21
0
votes
1 answer

How do I working with objects that can change from one client to another

I have a problem where I data for an object, for example billing file, where the data elements are different from client to client. More specifically the number of fields within the data and of different names. I am looking for a solution when…
Troy Crowe
  • 123
  • 2
  • 12
0
votes
2 answers

Providing a DynamicObject properties

I need a way to provide a Dynamic get members and set for a given class. I want to be able to write code like this: ns1.Resource.Field1 = "Hello"; string myField = ns1.Resource.Field1; where ns1 is the namespace and I believe that "Resource" is…
Haddar Macdasi
  • 3,477
  • 8
  • 37
  • 59
0
votes
0 answers

List ExpandoObject properties at run-time by pressing "dot" in Visual Studio

In our .NET Core project we have service references for SOAP APIs. But since we have a lot of them, we implemented a generic method which invokes the method in SoapClient so that we can just call: var response = await…
0
votes
1 answer

Let DynamicObect's TryGetMember and TrySetMember return a class in C#

I have a class inheriting from DynamicObject In this class I have a TryGetMember that I try to evaluate to a static class. How can TryGetMember overriden from DynamicObject result in a static class? TL;DR Calling code: dynamic sut = new…
LosManos
  • 7,195
  • 6
  • 56
  • 107
0
votes
1 answer

binding observable collection of custom objects containing array

i'm learning wpf and binding and all and i have a gridview and a custom object i'm trying to bind a list of custom objects to the grid my custom object is designed like this Public class myObject { protected int myInt {get; set;} …
Slite
  • 159
  • 2
  • 2
  • 13
0
votes
1 answer

Dynamic class creation using Dictionary

I have a class called CoverageBase with properties say A, B, C. And now based on some checks i need to append n number of properties say D and E properties in to this CoverageBase class along with my existing A, B, C. So for creating D and E…
Nithin Paul
  • 2,169
  • 3
  • 33
  • 55
0
votes
1 answer

WPF C# - Saving a Canvas with Dynamic Devices with Code Behind properties (variables)

We've searched all over stack overflow and similar sites for something that will work for our app, but everything gets us only halfway there. We have an application that allows the user to drag and drop devices onto a drop canvas. Upon the device…
Vertigo
  • 21
  • 5
0
votes
1 answer

How to expand a dynamic object wthout disrupting its existing members?

I have a dynamic object called Manifest and have members added in it like public dynamic manifest={ Type=30, components ={ .. something} } I want to expand this dynamic object to accomodate more members. What's the syntax…
the_coder_in_me
  • 143
  • 3
  • 15
0
votes
1 answer

Creating Azure Search Index with DynamicObjects as documents

I am attempting to upload a series of documents, belonging to a class which derives from DynamicObject. I require this due to the fact that the index fields might change when the index is recreated. Everything works fine with the index creation,…
0
votes
1 answer

How to work with a DynamicJsonObject's property values?

Let's say that in my WebAPI I'm receiving a json like this: { prop1: "sometext", prop2: 123, prop3: true, prop4: [1,2,3,4,5], prop5: ["text1", "text2", "text3"] } To work with this data, I transform it into this: dynamic data…
Pedro Corso
  • 557
  • 8
  • 22
0
votes
0 answers

How do I store dynamic data and bind it to a DataGridView?

I've been at this for a few days, and I can't seem to find the correct approach to bind dynamic data to a DataGridView. I'm downloading data from a web API that is delivered in JSON. Newtonsoft JSON deserializes the data and stores it in a dynamic.…
Prdufresne
  • 296
  • 2
  • 15