This project primarily focuses on parsing strings that represent the concentration of various elements in parts per million (ppm) and converting them into structured PpmTarget objects which can be further processed or analyzed within the system. The NPKTools.Optimizer.PpmTargetParser project is designed as a specialized component within the NPKTools suite, aimed at interpreting and transforming user input into actionable data models.
$ dotnet add package NPKTools.Optimizer.PpmTargetParserThe NPKTools.Optimizer.PpmTargetParser project is designed as a specialized component within the NPKTools suite, aimed at interpreting and transforming user input into actionable data models. This project primarily focuses on parsing strings that represent the concentration of various elements in parts per million (ppm) and converting them into structured PpmTarget objects which can be further processed or analyzed within the system.
This tool was developed by Anatoliy Yermakov.
Special thanks to Artem Frolov for his invaluable assistance and guidance in the development of this project.
This project is licensed under the MIT License.
This section guides you through setting up and configuring the necessary components for the project using Dependency Injection (DI).
To manually instantiate the components without using DI, use the following example:
using NPKTools.Optimizer.PpmTargetParser;
using NPKTools.Core.Domain.PpmTarget;
// Manually creating an instance of PpmTargetParser without DI
PpmTargetParser ppmTargetParser = new PpmTargetParser();
Using Dependency Injection For integrating these components into a project that supports Dependency Injection, such as an ASP.NET Core application, configure your services in the Startup.cs or a similar configuration file as follows:
public void ConfigureServices(IServiceCollection services)
{
// Registering services in the DI container
services.AddSingleton<IPpmTargetParser, PpmTargetParser>();
}
string input = "N=150, P=50, K=200, Ca=40, Mg=30";
try
{
PpmTarget target = ppmTargetParser.Parse(input);
Console.WriteLine("Parsing successful! Target values are set.");
}
catch (Exception ex)
{
Console.WriteLine($"Error parsing input: {ex.Message}");
}