/// <summary> /// Initializes a new instance of the <see cref="AssociationCoupler" /> class. /// </summary> /// <param name="existingAssociation">The existing association.</param> /// <param name="associate">The delegated to establish or remove association</param> /// <param name="title">The read only title of the association.</param> /// <param name="defaultAssociation">The association configuration wrapper.</param> public AssociationCoupler(IAssociationConfigurationWrapper existingAssociation, Action <bool, IAssociationConfigurationWrapper> associate, string title, IAssociationConfigurationWrapper defaultAssociation) { Associated = existingAssociation != null; m_Associate = associate; Title = title; AssociationWrapper = existingAssociation != null ? existingAssociation : defaultAssociation; }
/// <summary> /// Creates or removes association described by the parameter <paramref name="association" />. /// </summary> /// <param name="associate">if set to <c>true</c> the <paramref name="association" /> shall be added to the collection of associations.</param> /// <param name="association">The association instance of type <see cref="IAssociationConfigurationWrapper" /> to be added to the local collection.</param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="InvalidCastException"></exception> public override void Associate(bool associate, IAssociationConfigurationWrapper association) { if (association == null) { throw new ArgumentNullException(nameof(association)); } ProducerAssociationConfigurationWrapper _wrapper = association as ProducerAssociationConfigurationWrapper; if (_wrapper == null) { throw new InvalidCastException($"Imposible to cast {nameof(association)}"); } if (associate) { if (AssociationConfiguration.Where <ProducerAssociationConfigurationWrapper>(x => x.AssociationName == association.AssociationName).Any <ProducerAssociationConfigurationWrapper>()) { return; } List <ProducerAssociationConfigurationWrapper> _associations = new List <ProducerAssociationConfigurationWrapper>(AssociationConfiguration); _associations.Add(_wrapper); AssociationConfiguration = _associations.ToArray <ProducerAssociationConfigurationWrapper>(); } else { AssociationConfiguration = AssociationConfiguration.Where <ProducerAssociationConfigurationWrapper>(x => x.AssociationName != association.AssociationName).ToArray <ProducerAssociationConfigurationWrapper>(); } }
private IAssociationConfigurationWrapper DefaultAssociation(AssociationRole transportRole, DataSetConfigurationWrapper dsc) { IAssociationConfigurationWrapper _ret = null; switch (transportRole) { case AssociationRole.Consumer: _ret = ConsumerAssociationConfigurationWrapper.GetDefault(dsc); break; case AssociationRole.Producer: _ret = ProducerAssociationConfigurationWrapper.GetDefault(dsc); break; } return(_ret); }
/// <summary> /// Creates or removes association described by the parameter <paramref name="association" />. /// </summary> /// <param name="associate">if set to <c>true</c> the <paramref name="association" /> shall be added to the collection of associations.</param> /// <param name="association">The association instance of type <see cref="IAssociationConfigurationWrapper" /> to be added to the local collection.</param> public abstract void Associate(bool associate, IAssociationConfigurationWrapper association);