public AdaptingFromOneServiceToAnother() { var ad = new LightweightAdapterActivatorData(_from, (c, p, t) => new object()); var rd = new RegistrationData(_to); _subject = new LightweightAdapterRegistrationSource(rd, ad); _adaptedTo = _subject.RegistrationsFor(_to, s => _adaptedFrom); }
public void FromAndToMustDiffer() { var ad = new LightweightAdapterActivatorData(new TypedService(typeof(object)), (c, p, t) => new object()); var rd = new RegistrationData(new TypedService(typeof(object))); Assert.Throws<ArgumentException>(() => new LightweightAdapterRegistrationSource(rd, ad)); }
/// <summary> /// Initializes a new instance of the <see cref="LightweightAdapterRegistrationSource"/> class. /// </summary> /// <param name="registrationData">The registration data for the adapter.</param> /// <param name="activatorData">The activator data for the adapter.</param> public LightweightAdapterRegistrationSource( RegistrationData registrationData, LightweightAdapterActivatorData activatorData) { _registrationData = registrationData ?? throw new ArgumentNullException(nameof(registrationData)); _activatorData = activatorData ?? throw new ArgumentNullException(nameof(activatorData)); if (registrationData.Services.Contains(activatorData.FromService)) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, LightweightAdapterRegistrationSourceResources.FromAndToMustDiffer, activatorData.FromService)); } }
public LightweightAdapterRegistrationSource( RegistrationData registrationData, LightweightAdapterActivatorData activatorData) { if (registrationData == null) throw new ArgumentNullException(nameof(registrationData)); if (activatorData == null) throw new ArgumentNullException(nameof(activatorData)); _registrationData = registrationData; _activatorData = activatorData; if (registrationData.Services.Contains(activatorData.FromService)) throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, LightweightAdapterRegistrationSourceResources.FromAndToMustDiffer, activatorData.FromService)); }
public LightweightAdapterRegistrationSource(RegistrationData registrationData, LightweightAdapterActivatorData activatorData) { if (registrationData == null) { throw new ArgumentNullException("registrationData"); } if (activatorData == null) { throw new ArgumentNullException("activatorData"); } this._registrationData = registrationData; this._activatorData = activatorData; if (registrationData.Services.Contains <Service>(activatorData.FromService)) { throw new ArgumentException(string.Format(LightweightAdapterRegistrationSourceResources.FromAndToMustDiffer, activatorData.FromService)); } }