Core API Reference
This section provides a comprehensive overview of the core APIs available in the MSDN framework. These APIs form the foundation for building robust and scalable applications.
General Utilities
DateTime Class
Provides functionality for manipulating dates and times.
DateTime.Now(): Returns the current date and time.DateTime.Parse(string): Parses a string representation of a date and time.DateTime.ToString(format): Formats the date and time to a string.
// Example Usage
let now = DateTime.Now();
console.log(now.ToString("yyyy-MM-dd HH:mm:ss"));
StringHelper Module
Offers various utility methods for string manipulation.
StringHelper.IsNullOrEmpty(string): Checks if a string is null, empty, or whitespace.StringHelper.Contains(source, substring): Checks if a string contains a substring.StringHelper.Trim(string): Removes whitespace from both ends of a string.
// Example Usage
if (!StringHelper.IsNullOrEmpty(userName)) {
console.log("User name is valid.");
}
Console Object
Provides methods for interacting with the console output.
Console.Log(message): Writes a message to the console.Console.Error(message): Writes an error message to the console.Console.Clear(): Clears the console.
// Example Usage
Console.Log("Application started.");
Console.Error("Failed to load configuration.");
MathUtils Module
Contains mathematical functions and constants.
| Method/Property | Description | Signature |
|---|---|---|
MathUtils.PI |
The mathematical constant π. | number |
MathUtils.Sqrt(number) |
Returns the square root of a number. | (number) => number |
MathUtils.Abs(number) |
Returns the absolute value of a number. | (number) => number |
MathUtils.Max(a, b) |
Returns the larger of two numbers. | (a: number, b: number) => number |
ConfigurationManager
Manages application configuration settings.
This class allows you to access and manage configuration settings for your application, typically loaded from a configuration file.
ConfigurationManager.GetValue(key): Retrieves a configuration value by its key.ConfigurationManager.SetValue(key, value): Sets a configuration value.ConfigurationManager.Load(filePath): Loads configuration from a specified file path.
// Example Usage
ConfigurationManager.Load("appsettings.json");
let apiEndpoint = ConfigurationManager.GetValue("api:endpoint");
console.log(`API Endpoint: ${apiEndpoint}`);
Error Handling
The core API includes robust error handling mechanisms. Exceptions are thrown for critical errors, and specific error codes may be returned for less severe issues.
Common Exception Types
ArgumentNullException: Thrown when a null argument is passed to a method that does not accept it.InvalidOperationException: Thrown when a method is called at an inappropriate time or in an inappropriate state.FileNotFoundException: Thrown when a file that was expected to be found could not be located.