Forum Discussion

GriffinGSA's avatar
GriffinGSA
Occasional Visitor
6 years ago

C# - Fails for class derived from DynamicObject (not what you think)

Just because a class inherits from DynamicObject doesn't mean it's also not a normal class? Why do you just give up on a class that inherits from DynamicObject, it's commonly done and it can have strongly typed properties, for instance:

public class Credentials : DynamicObject
{
    public string Client_Id { get; set; }
    public string Username { get; set; }
    public string Password { get; set; }
    public string Audience { get; set; }
}

This offers many capabilities as a developer for things I won't go into here. However, suffice it to say if you treated this class a normal class (after all it is) then Swagger would work just fine. This class will serialize json and xml and everying else just fine, there is nothing wrong with a class that inherits from DynamicObject, it should not be treated as an abberation.

 

This class and it's properties are totally ignored ?? as a return type or an input type ?

No RepliesBe the first to reply