public void DefineProvider(QualifiedName name, Type providerType, Type providerInstanceType, object metadata = null) { if (providerType == null) { throw new ArgumentNullException("providerType"); } if (providerInstanceType == null) { throw new ArgumentNullException("providerInstanceType"); } if (providerInstanceType.GetTypeInfo().IsAbstract || !providerType.GetTypeInfo().IsAssignableFrom(providerInstanceType)) { throw RuntimeFailure.InvalidProviderInstanceType("providerInstanceType"); } var qn = GetName(name, providerInstanceType, providerInstanceType.Name); var tr = new ProviderType(providerInstanceType, providerType, qn); tr.ProviderMetadata = ProviderMetadataWrapper.Create(ApplyCompleter(providerInstanceType, providerType, metadata)); tr.ProviderMetadata.Source = tr; AppendResult(tr); }