Questions tagged [expandoobject]

ExpandoObject is a .NET type whose members can be added and removed at runtime.

From msdn: Represents an object whose members can be dynamically added and removed at run time.

Instances are typically declared with the dynamic keyword:

dynamic sampleObject = new ExpandoObject();

This type is part of System.Dynamic and was introduced with .NET 4.

356 questions
3
votes
1 answer

How to get ServiceStack to serialize a dynamic (ExpandoObject) property on request

Are there any extra configurations that are necessary to get ServiceStack to deserialize a JSON request into an appropriate dynamic object? I have compiled the Net40 version of the ServiceStack.Text library that includes the DynamicJson class and…
3
votes
1 answer

How to convert to List properly

Look at the below code private static List GetDBDetails() { var directoryPath = Environment.CurrentDirectory.Replace("\\bin\\Debug", "\\DataSource"); var filePath = Path.Combine(directoryPath,…
priyanka.sarkar
  • 25,766
  • 43
  • 127
  • 173
3
votes
0 answers

Patterns / Problems that use dynamic types, dynamic objects and expando objects in C#

I have recently become aware of the dynamic keyword after doing some digging into Dynamic Objects and Expando Objects in C# I can appreciate that it is quite cool however apart from a ViewBag in ASP.NET MVC I am struggling to find applications for…
AJM
  • 32,054
  • 48
  • 155
  • 243
3
votes
1 answer

How do I recursively traverse and log the properties of a HttpRequestMessage in C#?

Thanks for looking! Background I am working on an MVC4 .NET application and have written a filter to catch all errors (application-wide), log said errors, and then report them to the dev team via an HTML-formatted email. The filter I have written…
Matt Cashatt
  • 23,490
  • 28
  • 78
  • 111
3
votes
2 answers

Convert ExpandoObject to anonymous type

Is it possible to convert ExpandoObject to anonymously typed object? Currently I have HtmlHelper extension that can take HTML attributes as a parameter. The problem is that my extension also needs to add some HTML attributes so I've use…
xx77aBs
  • 4,678
  • 9
  • 53
  • 77
3
votes
2 answers

How to apply an Extension Method on the object having the type of ExpandoObject?

Here is my code: public static class DynamicExtensions public static void Add(this ExpandoObject obj, string path){ dynamic _obj = obj; if (_obj == null) throw new ArgumentNullException("obj"); _obj.path = path; …
zs2020
  • 53,766
  • 29
  • 154
  • 219
3
votes
1 answer

XML Dynamic Object and IEnumberables

I am having some issues with my DynamicXML object, it is parsing XML great, and for single elements works great, but when I have multiple children elements its falling over. I am obviously missing something, but I dont know what. Here is the…
JamesStuddart
  • 2,581
  • 3
  • 27
  • 45
3
votes
1 answer

Using dynamic objects in codedom created LINQ queries

I tried to use expandoobjects in LINQ queries to have the ability to query against properties that are created during runtime, for example the headers from a csv file. It all worked fine if typing the LINQ query direct in the code as in the…
Robin G
  • 33
  • 4
2
votes
1 answer

Accessing properties of anonymous/dynamic types across dll boundaries gives RuntimeBinderException

In the following sample, x.propertyX works fine, whereas y.propertyX gives me a Microsoft.CSharp.RuntimeBinder.RuntimeBinderException, complaining 'propertyX' is not defined in 'object'. The CreateDynamic method in the Program class (shown below)…
Evgeniy Berezovsky
  • 18,571
  • 13
  • 82
  • 156
2
votes
3 answers

How do I wrap an object in a dynamic object?

Given an System.Object, how do I get a dynamic object with which to access any members it might have. Specifically, I want to unit test an ASP.NET MVC 3 controller action which returns a JsonResult. The JsonResult has a Data property of type object.…
Greg B
  • 14,597
  • 18
  • 87
  • 141
2
votes
1 answer

Create C# class with constructor that acts as expando

I'm wondering is it possible to create a class that acts just Like ActiveXObject in earlier IE version and pass it over to MS ClearScript? I've found a piece of code that creates an instances of ActiveXObjects with their string name. class…
2
votes
0 answers

Is there a way to use FastMember ObjectReader over an expando/dynamic

Is there a way to use FastMember ObjectReader.Create over a list of ExpandoObject. Here is a simple test case that I made to test: using FastMember; using System; using System.Collections.Generic; using System.Data; using System.Dynamic; using…
billybob
  • 2,859
  • 6
  • 35
  • 55
2
votes
1 answer

Allow multiple values for the same key when creating JSON using ExpandoObject and IDictionary

I am trying to create dynamic JSON using ExpandoObject and IDictionary. During the dynamic creation of JSON there could be instances when the Name or Value would repeat. However when adding the repeated Name or Value to the ExpandoObject, it gives…
Mufaddal
  • 558
  • 5
  • 24
2
votes
2 answers

Convert Json to List

I'm currently working on a .NET Framework 4.7.2 application. I'm retrieving data from a Web API as a JSON string result, I need to convert the result into an IEnumerable or IList of ExpandoObject. my JSON can have dynamic properties and looks like…
timhorton42
  • 241
  • 5
  • 15
2
votes
0 answers

C# Check the values of dynamic object properites while debugging

I encountered a WCF service which returns a dynamic object. But in debug mode the properties of dynamic objects were not allowed to visible. How to see dynamic object property values while debugging. Image is attached.
Aslam Jiffry
  • 1,306
  • 6
  • 23
  • 57