예제 #1
0
 public EtiquetteDto(
     string id,
     EnumTypeBlock typeBlock,
     EnumExtremiteEtiquette extremite)
 {
     this.id        = id;
     this.typeBlock = typeBlock;
     this.extremite = extremite;
 }
예제 #2
0
 public BlockInfos(
     string id,
     EnumTypeBlock typeBlock,
     ElementConstructionDto donnees)
 {
     this.id        = id;
     this.typeBlock = typeBlock;
     this.donnees   = donnees;
 }
 public ElementEtiquetteConstructionDto(
     EnumTypeBlock typeBloc,
     string id,
     ElementConstructionDto element)
 {
     this.typeBloc = typeBloc;
     this.id       = id;
     this.element  = element;
 }
예제 #4
0
        public void Etiquetter(
            string id,
            EnumTypeBlock typeBlock,
            Etat etatEntree,
            Etat etatSortie)
        {
            try
            {
                // Récupération des infos sur les états en entrée et en sortie
                EtatInfos etatInfosEntree = null,
                          etatInfosSortie = null;

                using (lockeur.RecupererLockLecture())
                {
                    bool etatEntreeDansArbre = dicoEtatsInfos
                                               .TryGetValue(
                        etatEntree,
                        out etatInfosEntree);
                    bool etatSortieDansArbre = dicoEtatsInfos
                                               .TryGetValue(
                        etatSortie,
                        out etatInfosSortie);

                    if (!etatEntreeDansArbre ||
                        !etatSortieDansArbre)
                    {
                        throw new ExceptionTechniqueArbreConstruction(
                                  ExceptionBase.RecupererLibelleMessage());
                    }
                } // Note : on lève le verrou sur le dico pour maintenir les performances. On vérifie plus loin que les états existent encore (après les avoir lockés)...

                // Lock sur les états source et cible en évitant les inter-locks : lock toujours dans le même ordre
                var lockeurs = RecupererLockeurs(
                    etatInfosEntree,
                    etatInfosSortie);

                using (lockeurs[0].RecupererLockEcriture())
                {
                    if (!etatInfosEntree.EstActif)
                    {
                        throw new ExceptionTechniqueArbreConstruction(
                                  ExceptionBase.RecupererLibelleMessage());
                    }

                    etatEntree.Etiquette = new EtiquetteDto(
                        id,
                        typeBlock,
                        EnumExtremiteEtiquette.Entree);

                    etatInfosEntree
                    .InterdireTransitionSortante();
                }

                if (lockeurs.Length == 2)
                {
                    using (lockeurs[1].RecupererLockEcriture())
                    {
                        if (!etatInfosSortie.EstActif)
                        {
                            throw new ExceptionTechniqueArbreConstruction(
                                      ExceptionBase.RecupererLibelleMessage());
                        }

                        etatSortie.Etiquette = new EtiquetteDto(
                            id,
                            typeBlock,
                            EnumExtremiteEtiquette.Sortie);

                        etatInfosSortie
                        .InterdireTransitionEntrante();
                    }
                }
            }
            catch (Exception ex)
            {
                throw EncapsulerEtGererException <ExceptionTechniqueArbreConstruction>(
                          ex);
            }
        }