Example #1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="contractType">Required.</param>
 /// <param name="sharedInstance">Required.</param>
 /// <exception cref="ArgumentNullException"/>
 /// <exception cref="ArgumentException">If the <c>sharedInstance</c> does
 /// not extend the <c>contractType</c>.</exception>
 public SharedInstanceExportDescriptorProvider(Type contractType, object sharedInstance)
 {
     ContractType   = contractType ?? throw new ArgumentNullException(nameof(contractType));
     SharedInstance = sharedInstance ?? new ArgumentNullException(nameof(sharedInstance));
     if (!ContractType.IsInstanceOfType(SharedInstance))
     {
         throw new ArgumentException(
                   $"Shared instance '{SharedInstance.GetType().GetFriendlyFullName()}'"
                   + $" does not extend service contract type '{ContractType.GetFriendlyFullName()}'.");
     }
 }