private static void RegisterElementFinderBasedFactories(Type elementType) { ElementFinderBasedFactory elementFinderBasedFactory = CreateElementFinderBasedFactory(elementType); if (elementFinderBasedFactory == null) { throw new InvalidOperationException(String.Format("The element type '{0}' must have a constructor with signature .ctor(DomContainer, ElementFinder).", elementType)); } elementFinderBasedFactoriesByType.Add(elementType, elementFinderBasedFactory); }
private static void RegisterElementFinderBasedFactories(Type elementType) { var elementFinderBasedConstructor = elementType.GetConstructor(new[] { typeof(DomContainer), typeof(ElementFinder) }); if (elementFinderBasedConstructor == null) { throw new InvalidOperationException(String.Format("The element type '{0}' must have a constructor with signature .ctor(DomContainer, ElementFinder).", elementType)); } ElementFinderBasedFactory elementFinderBasedFactory = (container, elementFinder) => (Element)elementFinderBasedConstructor.Invoke(new object[] { container, elementFinder }); elementFinderBasedFactoriesByType.Add(elementType, elementFinderBasedFactory); }