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 }
public Faux() { var compiler = new WebServiceCompiler <TService>(); compiler.Verify(); Service = compiler.Generate(); }
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)); }
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)); } }
public Faux() { compiler = new WebServiceCompiler <TService>(); }