Wednesday 26 February 2020

Use of System.Environment Class and Why is XmlSerializer so slow

System.Environment Class
The System.Environment Class provides information about the current environment and platform. The System.Environment Class uses to retrieve Environment variable settings, Version of the common language runtime, contents of the call stack etc. This class cannot be inherited.
How to get Current working directory ?
System.Environment.CurrentDirectory - will return your current working directory
How to get Machine Name ?
System.Environment.MachineName - will return your current machine name.
How to get current Operating System Version ?
System.Environment.OSVersion.ToString () - will return your current operating system version
How to get the current user name of the system ?
System.Environment.UserName - will return your current user name
=====================

Why is XmlSerializer so slow?

The XmlSerializer It makes extensive use of reflection to extract information about the fields of an object. Any time reflection becomes involved, performance drops drastically. Another reason is that there is a once-per-process-per-type overhead with XmlSerializer. So the first time you serialize or deserialize an object of a given type in an application, there is a significant delay. This normally doesn't matter, but it may mean, for example, that XmlSerializer is a poor choice for loading configuration settings during startup of a GUI application.

XML Serialization

XML Serialization is the process of serializing a .Net Object to the form of XML or from an XML to .Net Object. The primary purpose of XML serialization in the .NET Framework is to enable the conversion of XML documents and streams to common language runtime objects and vice versa. This is the process of converting an object into a form that can be readily transported.

No comments:

Post a Comment

Baisic Useful Git Commands

  Pushing a fresh repository Create a fresh repository(Any cloud repository). Open terminal (for mac ) and command (windows) and type the be...