VetCore.Anmv.Utils 0.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package VetCore.Anmv.Utils --version 0.0.5
                    
NuGet\Install-Package VetCore.Anmv.Utils -Version 0.0.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VetCore.Anmv.Utils" Version="0.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VetCore.Anmv.Utils" Version="0.0.5" />
                    
Directory.Packages.props
<PackageReference Include="VetCore.Anmv.Utils" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add VetCore.Anmv.Utils --version 0.0.5
                    
#r "nuget: VetCore.Anmv.Utils, 0.0.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package VetCore.Anmv.Utils@0.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=VetCore.Anmv.Utils&version=0.0.5
                    
Install as a Cake Addin
#tool nuget:?package=VetCore.Anmv.Utils&version=0.0.5
                    
Install as a Cake Tool

VetCore.Anmv.Utils

Build and test NuGet NuGet Downloads

Une bibliothèque utilitaire en .NET pour valider, sérialiser, et manipuler les fichiers XML de l'ANMV (Agence Nationale du Médicament Vétérinaire). Elle inclut les XSD officiels intégrés pour garantir la conformité.


Fonctionnalités principales

  • Désérialisation facile : Transformez les fichiers XML Data et Description en objets DTO typés.
  • Validation XML avec XSD : Validez vos fichiers XML à l'aide des XSD officiels fournis.
  • Génération de XSD : Génération de fichiers XSD à partir de types DTO.
  • Sérialisation en XML : Transformez vos DTO en chaînes XML.
  • Accès aux XSD officiels intégrés : Les fichiers XSD Data et Description sont directement accessibles depuis les ressources embarquées.

Installation

Ajoutez cette bibliothèque à votre projet via NuGet :

dotnet add package VetCore.Anmv.Utils

Utilisation

1. Désérialisation des fichiers XML

Exemple pour un fichier Data
using System.IO;
using VetCore.Anmv.Utils;
using VetCore.Anmv.Xml.Data;

var dataFile = new FileInfo("path/to/data.xml");

// Désérialiser un fichier Data
var dataDto = AnmvFileHandler.DeserializeDataFile(dataFile);

Console.WriteLine($"Jeu de données du : {dataDto?.Informations.DateJeuDeDonnees}");
foreach (var product in dataDto?.MedicinalProducts ?? Enumerable.Empty<MedicinalProductDto>())
{
    Console.WriteLine($"Produit : {product.Nom}, Numéro AMM : {product.NumAmm}");
}
Exemple pour un fichier Description
using System.IO;
using VetCore.Anmv.Utils;
using VetCore.Anmv.Xml.Descriptions;

var descriptionFile = new FileInfo("path/to/description.xml");

// Désérialiser un fichier Description
var descriptionDto = AnmvFileHandler.DeserializeDescriptionFile(descriptionFile);

foreach (var entry in descriptionDto?.TermNat ?? Enumerable.Empty<EntryDto>())
{
    Console.WriteLine($"Nature : {entry.SourceCode} - {entry.SourceDesc}");
}

2. Validation des fichiers XML avec un XSD

Exemple : Valider un fichier XML Data
using System.IO;
using VetCore.Anmv.Utils;
using VetCore.Anmv.Utils.Xsd;

var xmlFile = new FileInfo("path/to/data.xml");
var xsdContent = AmnvFilesKey.Data_XSD_AMM.GetXsdContent();

// Valider le fichier XML avec le XSD
var result = AnmvFileHandler.ValidateXmlWithXsd(xmlFile, xsdContent);

if (result.Errors.Count == 0)
{
    Console.WriteLine("Validation réussie !");
}
else
{
    Console.WriteLine("Erreurs de validation :");
    Console.WriteLine(result.PrintErrorsAndWarnings());
}

3. Génération de XSD depuis un type DTO

Générez un fichier XSD à partir de n'importe quel type DTO pour des besoins spécifiques :

using VetCore.Anmv.Utils;

var xsd = AnmvFileHandler.GenerateXsdFromDtoType(typeof(MedicinalProductGroupDto));
Console.WriteLine($"XSD généré :\n{xsd}");

4. Sérialisation des DTO en XML

Exemple pour un fichier Data
using VetCore.Anmv.Utils;
using VetCore.Anmv.Xml.Data;

var dto = new MedicinalProductGroupDto
{
    Informations = new InformationsDto { DateJeuDeDonnees = DateTime.Now },
    MedicinalProducts = new List<MedicinalProductDto>
    {
        new MedicinalProductDto { Nom = "NEOMYCINE", NumAmm = "0033630" }
    }
};

var xml = dto.SerializeAmnvToXml(indent: true);
Console.WriteLine($"XML généré :\n{xml}");

5. Accès aux fichiers XSD intégrés

Les XSD officiels sont embarqués dans la bibliothèque et accessibles via AmnvFilesKey et XsdAnmvFileAccessor.

Exemple : Obtenir un fichier XSD en tant que contenu texte
using VetCore.Anmv.Utils.Xsd;

var xsdContent = AmnvFilesKey.Data_XSD_AMM.GetXsdContent();
Console.WriteLine($"Contenu du XSD Data :\n{xsdContent}");

Contributions

Les contributions sont les bienvenues ! Soumettez une pull request ou ouvrez une issue sur notre GitHub pour proposer des améliorations ou signaler des problèmes.


Licence

Ce projet est sous licence MIT. Consultez le fichier LICENSE pour plus d'informations.


Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 135 2/19/2025
1.0.0 116 2/18/2025
0.0.7 100 1/16/2025
0.0.6 84 1/14/2025
0.0.5 113 12/20/2024
0.0.4 109 12/20/2024
0.0.3 109 12/20/2024
0.0.2 103 12/20/2024
0.0.1 106 12/20/2024