void ThrowIfSubFeatureAlradyAdded(ISubFeature subFeature) { if (_subFeatures.Contains(subFeature)) { throw new SubFeatureAlreadyAddedToFeature(this, subFeature); } }
/// <inheritdoc/> public void AddSubFeature(ISubFeature subFeature) { ThrowIfSubFeatureAlradyAdded(subFeature); _subFeatures.Add(subFeature); }
/// <summary> /// Initializes a new instance of <see cref="SubFeatureAlreadyAddedToFeature"/> /// </summary> /// <param name="feature"><see cref="IFeature">Feature</see> the sub feature is already added to</param> /// <param name="subFeature"><see cref="ISubFeature">Sub feature</see> that is already added</param> public SubFeatureAlreadyAddedToFeature(IFeature feature, ISubFeature subFeature) : base($"Feature '{subFeature.Name}' has already been added to the feature '{subFeature.Name}'") { }