Posts

Showing posts with the label object

How do I detect an ExpandoObject vs a Dynamic Object?

How do I detect an ExpandoObject vs a Dynamic Object? How to I determine if a Type is an ExpandoObject vs a Dynamic object? This is returning true for both: public static bool IsDynamicObject(Type type) { return typeof(IDynamicMetaObjectProvider).IsAssignableFrom(type); } Example Code for Dynamic Object: public class Entity { public Guid Id { get; set; } public String Name { get; set; } } Delta<Entity> x = new Delta<Entity>(); dynamic dynamicX = x; dynamicX.Name = nameof(Entity); dynamicX.Id = typeof(Entity).GUID; Example Code for Expando Object: dynamic childX = new ExpandoObject(); childX.A = 1; Why do you mean "a dynamic object"? See here and here for why I'm asking. dynamic a = 5; doesn't have a different type - it's an int , but then assigning a = "hello"; makes it a string . – john Jul 1 at 3:13 ...