Beispiel #1
0
        public static TInterface Implement <TInterface>(ILibrary library, Func <string, string> lookupFunctionName = null)
            where TInterface : class
        {
            if (library == null)
            {
                throw new ArgumentNullException("library");
            }

            var mapper = new LibraryInterfaceMapper(new DelegateTypeBuilder(),
                                                    new DefaultConstructorBuilder(lookupFunctionName),
                                                    new DefaultMethodCallWrapper());

            return(mapper.Implement <TInterface>(library));
        }
Beispiel #2
0
        public static TInterface Implement <TInterface>(ILibrary library, IMethodCallProbe <TInterface> probe, Func <string, string> lookupFunctionName = null)
            where TInterface : class
        {
            if (library == null)
            {
                throw new ArgumentNullException("library");
            }
            if (probe == null)
            {
                throw new ArgumentNullException("probe");
            }

            var constructorBuilder = new ProbingConstructorBuilder(lookupFunctionName);
            var methoCallWrapper   = new ProbingMethodCallWrapper(() => constructorBuilder.ProbeField);
            var mapper             = new LibraryInterfaceMapper(new DelegateTypeBuilder(), constructorBuilder, methoCallWrapper);

            return(mapper.Implement <TInterface>(library, probe));
        }