예제 #1
0
        public static Type GetCompiledType(string inputFile, HttpContext context)
        {
#if NET_2_0
            return(BuildManager.GetCompiledType(inputFile));
#else
            string      physPath;
            HttpRequest req = context != null ? context.Request : null;

            if (req != null)
            {
                physPath = req.MapPath(inputFile);
            }
            else             // likely to fail
            {
                physPath = inputFile;
            }

            WebServiceParser parser = new WebServiceParser(context, inputFile, physPath);
            Type             type   = parser.GetCompiledTypeFromCache();
            if (type != null)
            {
                return(type);
            }

            return(WebServiceCompiler.CompileIntoType(parser));
#endif
        }
예제 #2
0
        public Faux()
        {
            var compiler = new WebServiceCompiler <TService>();

            compiler.Verify();

            Service = compiler.Generate();
        }
예제 #3
0
        public static Type GetCompiledType(HttpContext context, string virtualPath, string physicalPath)
        {
            WebHandlerParser parser = new WebHandlerParser(context, virtualPath, physicalPath);
            Type             type   = parser.GetCompiledTypeFromCache();

            if (type != null)
            {
                return(type);
            }

            return(WebServiceCompiler.CompileIntoType(parser));
        }
예제 #4
0
        private static void GenerateAssembly(CommandLineOptions opts)
        {
            var outputAssembly = opts.OutputAssemblyName ?? $"Generated.{Path.GetFileName(opts.InputAssemblyPath)}";
            var assembly       = Assembly.LoadFile(opts.InputAssemblyPath);
            var compiler       = new WebServiceCompiler();

            WebServiceClassGenerator.RootNamespace         = opts.RootNameSapce ?? WebServiceClassGenerator.RootNamespace;
            WebServiceClassGenerator.OutputSourceFiles     = opts.OutputSourceCode;
            WebServiceClassGenerator.SourceFilePath        = opts.OutputSourcePath ?? WebServiceClassGenerator.SourceFilePath;
            WebServiceClassGenerator.GenerateSealedClasses = !opts.UseUnsealedClasses;

            foreach (var iface in assembly.GetExportedTypes())
            {
                if (iface.IsInterface && iface.GetCustomAttribute <FauxClientAttribute>() != null)
                {
                    compiler.RegisterInterface(iface.GetTypeInfo());
                }
            }

            using (var stream = new FileStream(outputAssembly, FileMode.Create))
            {
                compiler.Compile(stream, Path.GetFileName(outputAssembly));
            }
        }
예제 #5
0
 public Faux()
 {
     compiler = new WebServiceCompiler <TService>();
 }