public void DefineProvider(QualifiedName name,
                                   Type providerType,
                                   MethodInfo factoryMethod,
                                   object metadata = null)
        {
            if (providerType == null)
            {
                throw new ArgumentNullException("providerType");
            }
            if (factoryMethod == null)
            {
                throw new ArgumentNullException("factoryMethod");
            }
            if (!factoryMethod.IsStatic ||
                !providerType.IsAssignableFrom(factoryMethod.ReturnType))
            {
                throw RuntimeFailure.InvalidProviderFieldOrMethod("factoryMethod");
            }

            var qn           = GetName(name, factoryMethod.DeclaringType, factoryMethod.Name);
            var methodResult = new ProviderMethod(factoryMethod,
                                                  providerType,
                                                  qn);

            methodResult.ProviderMetadata        = ProviderMetadataWrapper.Create(metadata);
            methodResult.ProviderMetadata.Source = methodResult;
            AppendResult(methodResult);
        }
        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);
        }
示例#3
0
 public int MatchCriteria(object criteria)
 {
     return(MatchMemberCriteria(this.Source, criteria)
            + ProviderMetadataWrapper.MemberwiseEquals(value, criteria));
 }
示例#4
0
 private int MatchMemberCriteria(object criteria)
 {
     return(ProviderMetadataWrapper.MatchMemberCriteria(
                ((IProviderMetadata)this).Source, criteria));
 }
示例#5
0
 protected virtual int MatchCriteriaCore(object criteria)
 {
     return(ProviderMetadataWrapper.MemberwiseEquals(this, criteria));
 }