VetCore.Anmv.Utils 0.0.7

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.7                
NuGet\Install-Package VetCore.Anmv.Utils -Version 0.0.7                
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.7" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VetCore.Anmv.Utils --version 0.0.7                
#r "nuget: VetCore.Anmv.Utils, 0.0.7"                
#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.
// Install VetCore.Anmv.Utils as a Cake Addin
#addin nuget:?package=VetCore.Anmv.Utils&version=0.0.7

// Install VetCore.Anmv.Utils as a Cake Tool
#tool nuget:?package=VetCore.Anmv.Utils&version=0.0.7                

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

Validation d'un fichier XML Description:
using VetCore.Anmv.Utils;
using VetCore.Anmv.Utils.Xsd;

FileInfo xmlFile = new FileInfo("path/to/file.xml");

// Valider le fichier XML avec le XSD de Description
var validationResult = AnmvFileHandler.ValidateXml(xmlFile, AmnvFilesKey.Descriptions_XSD_AMM);

if (validationResult.Errors.Count == 0)
{
    Console.WriteLine("Validation réussie !");
}
else
{
    Console.WriteLine(validationResult.PrintErrorsAndWarnings(Environment.NewLine));
}
Validation d'un fichier XML Données :
using VetCore.Anmv.Utils;
using VetCore.Anmv.Utils.Xsd;

FileInfo xmlFile = new FileInfo("path/to/file.xml");

// Valider le fichier XML avec le XSD de DATA (changement de la clé AmnvFilesKey utilisée)
var validationResult = AnmvFileHandler.ValidateXml(xmlFile, AmnvFilesKey.Data_XSD_AMM);

if (validationResult.Errors.Count == 0)
{
    Console.WriteLine("Validation réussie !");
}
else
{
    Console.WriteLine(validationResult.PrintErrorsAndWarnings(Environment.NewLine));
}

3. 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}");

4. 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;

// Récupérer le contenu XSD pour les données (en string)
string dataXsd = AmnvFilesKey.Data_XSD_AMM.GetXsdContent();

// Récupérer le contenu XSD pour la description (en string)
string descriptionXsd = AmnvFilesKey.Descriptions_XSD_AMM.GetXsdContent();

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. 
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 77 2/19/2025
1.0.0 78 2/18/2025
0.0.7 75 1/16/2025
0.0.6 32 1/14/2025
0.0.5 88 12/20/2024
0.0.4 77 12/20/2024
0.0.3 90 12/20/2024
0.0.2 83 12/20/2024
0.0.1 82 12/20/2024