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
1 answer

C# Invalid Option Error deserializing nested dynamic object with system.text.json in .Net 6

I'm working with a lot of media files and turning their properties into a dynamic object to process them in VS 2022, C#, .Net 6 Core, and system.text.json. Most of the files have nested parameters. Since every audio/video file has a different type…
Velocedge
  • 1,222
  • 1
  • 11
  • 35
0
votes
0 answers

.NET 6 “core” Create Dynamic Object containing List

How do I create a dynamic object that contains another dynamic object in a list? Let's say I normally have the following non dynamic classes. Public Class Foo { public bool IsSomething { get; set; } = false; public…
Lana North
  • 69
  • 2
  • 8
0
votes
1 answer

Ensuring anonymous objects in C# all have certain common properties

I have a problem regarding anonymous objects in C#. The situation is as follows: I have a C# web app which does NOT use the traditional ASP.NET Razor engine, but instead uses the RazorEngine open source project…
dabs
  • 727
  • 1
  • 7
  • 23
0
votes
1 answer

C# Custom DynamicObject cast to derived object

I have a class DocumentObject that extends DynamicObject to allow dynamic membership attributes. public class DocumentObject : DynamicObject { /// /// Inner dictionary that holds the dynamic members of the object …
chiaDev
  • 389
  • 3
  • 17
0
votes
0 answers

How to read a value in Dynamic object obtained from JsonConvert.DeserializeObject

I am using httpClient to an API endpoint. There are a couple of possible JSON results I could get back depending on if the call if successful or not. So I want to use a dynamic or ExpandoObject to DeserializeObject the results to. However, I can't…
Brad Mathews
  • 1,567
  • 2
  • 23
  • 45
0
votes
0 answers

Json.NET PopulateObject method does not work but DeserializeObject method works for the same type and JSON input

I have a custom type that derives from a DynamicObject and implements the IDictionary interface. In order to make this setup work with Json.NET, I use a custom contract resolver (here is a post where I talked about this usecase).…
B Singh
  • 113
  • 1
  • 9
0
votes
1 answer

dynamic object creation and function call

The problem is to call Honda class display method. Which class method will be called depends upon the string variable that will be passed at runtime. Here I have used one parent class of Honda so that I can achieve runtime polymorphism. But then I…
sakshi singhal
  • 101
  • 2
  • 9
0
votes
1 answer

C# index to dynamic object variable works in method but not when returned, Error C50021

I have a method that uses MediaInfo.exe to get information from a video file and returns a dynamic object. When the code runs, the information is readable inside the method but when I return the dynamic object, it throws a RuntimeBinderException…
Velocedge
  • 1,222
  • 1
  • 11
  • 35
0
votes
3 answers

Creating an object with a subset of properties and their values from another object

Consider the following class - public class User { [Selected] public string Name { get; set; } public string Email { get; set; } public string Password { get; set; } [Selected] public int Code { get; set; } public…
atiyar
  • 7,762
  • 6
  • 34
  • 75
0
votes
1 answer

How create a .net core MVC Model using dynamic object class?

I am looking for a code example to illustrate how to create a Model class in .net core MVC using C#, where the class has dynamic properties. My API receives a http POST request and I am creating one property for each HTTP header in the HeadersModel…
Mali Tbt
  • 679
  • 1
  • 8
  • 12
0
votes
0 answers

Typecasting dynamic object to class type passed in parameter in C#

I am trying to typecast object inside dynamic object to a type which is passed as a parameter. I searched but couldn't find any specific solution to the issue. Firstly the structure of the class is as under: [DataContract(Namespace = "")] …
0
votes
0 answers

C# JObject dynamic object access values issue

So I've got a JSON string that I'm handling with json.net. I'm putting this into a dynamic object and then just accessing the values from that. dynamic data = JObject.Parse(JsonString); if(data !=null) { string names = data.names.all int…
cooltrain
  • 31
  • 1
  • 7
0
votes
1 answer

c# using dynamic tools

in c# form application, when i click the button i create a listBox. and I add Item to the ListBox from a TextBox When I click the button, I want the listBox to be created if it does not exist. Therefore when assigning the ListBox creation code to…
0
votes
1 answer

Attach eventListener on dynamically created input text

i would like to attach eventListener to dynamically created input Text or other objects. Since the objects are not yet present in the DOM or the objects are not visible, attaching an event to these object fails. There's a proper way in plain…
AmiStack
  • 23
  • 7