/// <summary> /// Création d'un nouveau contrat /// </summary> /// <param name="port">The port.</param> /// <param name="layer">The layer.</param> /// <returns></returns> private static ServiceContract CreateContract(CandleElement port, InterfaceLayer layer) { string name = StrategyManager.GetInstance(port.Store).NamingStrategy.CreateElementName(layer, port.RootName); // Vérification de l'existence foreach (ServiceContract sc in layer.ServiceContracts) { if (sc.Name == name) { return(sc); } } // Sinon création avec copie des opérations ServiceContract contract = new ServiceContract(layer.Store); layer.ServiceContracts.Add(contract); contract.RootName = port.RootName; UnplacedModelHelper.RegisterNewModel(layer.Store, contract); TypeWithOperations copiedContract = null; if (port != null) { if (port is ServiceContract || port is ExternalServiceContract) { copiedContract = port as TypeWithOperations; contract.Name = name; } else { ClassImplementation clazz = port as ClassImplementation; contract.Name = StrategyManager.GetInstance(clazz.Store).NamingStrategy.CreateElementName(layer, clazz.Name); if (clazz.Contract != null) { copiedContract = clazz.Contract; } contract.Comment = clazz.Comment; } } if (copiedContract != null) { TypeWithOperations.CopyOperations(copiedContract, contract); } return(contract); }