Posts

Showing posts from May, 2022

How to dynamically add Properties in C# .NET?

Image
There are certain situations where we have to create object dynamically with properties added to the object dynamically. Data related to these properties may be coming in from external sources like a file or from any other serialized format. We can achieve this with the help of reflection, but it is bit complex and should have some prior knowledge of Reflection. What is meant by Dynamic Creation of Properties in c#? Dynamic creation of properties means at the time of writing the code, programmer is not aware of the properties which can be part of the object and its value. For Example there may be some data which needs to be read from say xml file, In this case there should be some organized way by which we can represent the data, This can be in the form of a object. Content of this object and the properties cannot be deduced while writing the application, it needs to be constructed from the xml file which is read when the application runs. Expando Object Expando Object comes to the res...

How to Use OWIN to Self-Host ASP.NET Web API?

Image
  In a Service Oriented architecture where there are multiple services serving the request from different clients it becomes imperative to add additional capabilities to these services and allow the Services to describe itself. What is meant by Self-Hosting? Self Hosting is a term used commonly to host a web Application or a Backend Service in a custom exe like console application instead of hosting it in IIS or some other exe. It is normally done to reduce the bulkiness and additional overhead which comes with external hosting platforms. What is OWIN? OWIN stands for Open Web Interface for .NET which basically acts as a abstraction between the Web Application and the Web Server so this means that Web Application is no more tightly bound to the Web Server which is hosting the application. OWIN  provides some standard API through which the Web Server can communicate with the Web Application. It also provides some middleware functionality through which it is possible to add pipe...