Example #1
0
        private KeyValuePair <string, ImplementationCreationInfo> ConvertPair(InterfaceImplementationTypePair pair)
        {
            var serviceName = pair.Interface.GetServiceName();

            if (!pair.Interface.IsAssignableFrom(pair.ImplementationType))
            {
                throw new ArgumentException(string.Format("Given implementation for a '{0}' service ({1}) does not implement its interface", serviceName, pair.ImplementationType.FullName));
            }
            var constructor = FindLargestAppropriateConstructor(pair.ImplementationType);

            if (constructor == null)
            {
                throw new ArgumentException(string.Format("No appropriate constructor found for {0}", pair.ImplementationType.FullName));
            }
            var creationInfo = new ImplementationCreationInfo
            {
                Constructor = constructor,
                Description = serviceDescriptionBuilder.Build(pair.Interface)
            };

            return(new KeyValuePair <string, ImplementationCreationInfo>(pair.Interface.GetServiceName(), creationInfo));
        }
 private KeyValuePair<string, ImplementationCreationInfo> ConvertPair(InterfaceImplementationTypePair pair)
 {
     var serviceName = pair.Interface.GetServiceName();
     if (!pair.Interface.IsAssignableFrom(pair.ImplementationType))
         throw new ArgumentException(string.Format("Given implementation for a '{0}' service ({1}) does not implement its interface", serviceName, pair.ImplementationType.FullName));
     var constructor = FindLargestAppropriateConstructor(pair.ImplementationType);
     if (constructor == null)
         throw new ArgumentException(string.Format("No appropriate constructor found for {0}", pair.ImplementationType.FullName));
     var creationInfo = new ImplementationCreationInfo
         {
             Constructor = constructor,
             Description = serviceDescriptionBuilder.Build(pair.Interface)
         };
     return new KeyValuePair<string, ImplementationCreationInfo>(pair.Interface.GetServiceName(), creationInfo);
 }