Esempio n. 1
0
        static void Main(string[] args)
        {
            // Sujet : installer packages
            // Microsoft.Extensions.Configuration
            // Microsoft.Extensions.Configuration.FileExtensions
            // Microsoft.Extensions.Configuration.Json
            // Unity
            // Créer le fichier "appsettings.json"
            // Ajoutez le contenu :
            // où ...
            // Modifiez le propriété du fichier pour qu'il soit copié au moment de la compilation
            // Copier dans le répertoire de sortie, sélectionnez "Copier si plus récent"

            IConfigurationRoot configuration = new ConfigurationBuilder()
                                               .SetBasePath(Directory.GetParent(AppContext.BaseDirectory).FullName)
                                               .AddJsonFile("appsettings.json", false)
                                               .Build();

            string repertoireDepotClient = configuration["RepertoireDepotsClients"];
            string nomFichierDepotClient = configuration["NomFichierDepotClients"];
            string cheminComplet         = Path.Combine(repertoireDepotClient, nomFichierDepotClient);

            if (!File.Exists(cheminComplet))
            {
                throw new InvalidOperationException($"Le fichier {cheminComplet} n'existe pas ou est inaccessible");
            }

            string typeDepot = configuration["TypeDepot"];

            IUnityContainer conteneur = new UnityContainer();

            conteneur.RegisterInstance(configuration, InstanceLifetime.Singleton);

            switch (typeDepot.ToLower())
            {
            case "json":
                conteneur.RegisterType <IDepotClients, DepotClientsJSON>(TypeLifetime.Singleton, new Unity.Injection.InjectionConstructor(new object[] { cheminComplet }));
                break;

            case "xml":
                conteneur.RegisterType <IDepotClients, DepotClientsXML>(TypeLifetime.Singleton, new Unity.Injection.InjectionConstructor(new object[] { cheminComplet }));
                break;

            default:
                throw new InvalidOperationException("le type de dépot n'est pas valide, mettre json ou xml");
            }


            ITraitementLot tl = null;

            tl = conteneur.Resolve <ModifierNomPrenomPremiereLettreMajusculesTraitementLot>();
            tl.Executer();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            GenererFichiersDepotSiNonExistant(false);

            IUnityContainer conteneur = new UnityContainer();

            conteneur.RegisterType <IDepotClients, DepotClientsXML>(TypeLifetime.Singleton, new Unity.Injection.InjectionConstructor(new object[] { _fichierDepotClientsXML }));
            //conteneur.RegisterType<IDepotClients, DepotClientsJSON>(TypeLifetime.Singleton, new Unity.Injection.InjectionConstructor(new object[] { _fichierDepotClientsJSON }));

            ClientUIConsole clientUIConsole = conteneur.Resolve <ClientUIConsole>();
            //clientUIConsole.ExecuterUI();

            ITraitementLot tl = null;

            tl = conteneur.Resolve <TraitementLot.ModifierNomPrenomPremiereLettreMajuscules.ModifierNomPrenomPremiereLettreMajusculesTraitementLot>();
            tl.Executer();
            tl = conteneur.Resolve <TraitementLot.ModifierPaysMajusculesClients.ModifierPaysMajusculesClientsTraitementLot>();
            tl.Executer();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            IConfigurationRoot configuration = new ConfigurationBuilder()
                                               .SetBasePath(Directory.GetParent(AppContext.BaseDirectory).FullName)
                                               .AddJsonFile("appsettings.json", false)
                                               .Build();

            string repertoireDepotClient = configuration["RepertoireDepotsClients"];
            string nomFichierDepotClient = configuration["NomFichierDepotClients"];
            string cheminComplet         = Path.Combine(repertoireDepotClient, nomFichierDepotClient);

            if (!File.Exists(cheminComplet))
            {
                throw new InvalidOperationException($"Le fichier {cheminComplet} n'existe pas ou est inaccessible");
            }

            string typeDepot = configuration["TypeDepot"];

            IUnityContainer conteneur = new UnityContainer();

            conteneur.RegisterInstance(configuration, InstanceLifetime.Singleton);

            switch (typeDepot.ToLower())
            {
            case "json":
                conteneur.RegisterType <IDepotClients, DepotClientsJSON>(TypeLifetime.Singleton, new Unity.Injection.InjectionConstructor(new object[] { cheminComplet }));
                break;

            case "xml":
                conteneur.RegisterType <IDepotClients, DepotClientsXML>(TypeLifetime.Singleton, new Unity.Injection.InjectionConstructor(new object[] { cheminComplet }));
                break;

            default:
                throw new InvalidOperationException("le type de dépot n'est pas valide, mettre json ou xml");
            }


            ITraitementLot tl = null;

            tl = conteneur.Resolve <ModifierPaysMajusculesClientsTraitementLot>();
            tl.Executer();
        }
Esempio n. 4
0
                static void Main(string[]  args)
                 {
                        GenererFichiersDepotSiNonExistant(false);

                        IUnityContainer conteneur  =  new UnityContainer();

                        conteneur.RegisterType <IDepotClients,  DepotClientsXML>(TypeLifetime.Singleton,  new Unity.Injection.InjectionConstructor(new object[]   {
                 _fichierDepotClientsXML 
            }));
                        //conteneur.RegisterType<IDepotClients, DepotClientsJSON>(TypeLifetime.Singleton, new Unity.Injection.InjectionConstructor(new object[] { _fichierDepotClientsJSON }));

                            ClientUIConsole clientUIConsole  =  conteneur.Resolve <ClientUIConsole>();
                        //clientUIConsole.ExecuterUI();

                            ITraitementLot tl  =  null;

                        tl  =  conteneur.Resolve <TraitementLot.ModifierNomPrenomPremiereLettreMajuscules.ModifierNomPrenomPremiereLettreMajusculesTraitementLot>();
                        tl.Executer();
                        tl  =  conteneur.Resolve <TraitementLot.ModifierPaysMajusculesClients.ModifierPaysMajusculesClientsTraitementLot>();
                        tl.Executer();
                    
        }