1 year ago

#275230

test-img

Yukesh.M

how to load class at runtime in c# vsix project

I can able to create the class for the Json. But how to load the generated class at runtime for deserialization operation in vsix project.

//json for generating class

[ { "Id": 1, "Name": "Alpha", "Gender": "Female", "KnownLanguages": [ "c#", "Javascript" ] }, { "Id": 2, "Name": "Alexa", "Gender": "Female", "KnownLanguages": [ "Python", "Java" ] }, { "Id": 3, "Name": "Mark ", "Gender": "Male", "KnownLanguages": [ "c", "Javascript" ] } ]

//creating class dynamically with respect to the json //schemaFile consist of json data

var classGenerator = new CSharpGenerator(schemaFile, new CSharpGeneratorSettings { ClassStyle = CSharpClassStyle.Poco, Namespace = "JsonModifier" });

//generate student class file

var codeFile = classGenerator.GenerateFile();

//writes the generated student class in the Student.cs file

 File.WriteAllText("JsonModifier\\Model\\Student.cs", codeFile);

//selectedText have the data for deserializing

JsonConvert.DeserializeObject<Student>(selectedText);

In this above deserialization i hardcoded the class name, but i need to load the class dynamically. How to do it?

c#

json

deserialization

vsix

.net-framework-version

0 Answers

Your Answer

Accepted video resources