private RpcClientBuilder(RpcServer server, RpcClientBuilderArguments args) { _server = server; _type_descriptors = new Dictionary <NdrBaseTypeReference, RpcTypeDescriptor>(); _args = args; _proc_names = new HashSet <string>(); }
/// <summary> /// Build a C# source file for the RPC client. /// </summary> /// <param name="server">The RPC server to base the client on.</param> /// <param name="args">Additional builder arguments.</param> /// <returns>The C# source code file.</returns> public static string BuildSource(RpcServer server, RpcClientBuilderArguments args) { CodeDomProvider provider = new CSharpCodeProvider(); CodeGeneratorOptions options = new CodeGeneratorOptions { IndentString = " ", BlankLinesBetweenMembers = false, VerbatimOrder = true, BracingStyle = "C" }; return(BuildSource(server, args, provider, options)); }
/// <summary> /// Compile an in-memory assembly for the RPC client. /// </summary> /// <param name="server">The RPC server to base the client on.</param> /// <param name="args">Additional builder arguments.</param> /// <param name="ignore_cache">True to ignore cached assemblies.</param> /// <param name="provider">Code DOM provider to compile the assembly.</param> /// <returns>The compiled assembly.</returns> /// <remarks>This method will cache the results of the compilation against the RpcServer.</remarks> public static Assembly BuildAssembly(RpcServer server, RpcClientBuilderArguments args, bool ignore_cache, CodeDomProvider provider) { var builder = new RpcClientBuilder(server, args); if (ignore_cache) { return(builder.Compile(builder.Generate(), provider)); } var key = Tuple.Create(server, args); if (!_compiled_clients.ContainsKey(key)) { _compiled_clients[key] = builder.Compile(builder.Generate(), provider); } return(_compiled_clients[key]); }
/// <summary> /// Create an instance of an RPC client. /// </summary> /// <param name="server">The RPC server to base the client on.</param> /// <param name="args">Additional builder arguments.</param> /// <returns>The created RPC client.</returns> /// <remarks>This method will cache the results of the compilation against the RpcServer.</remarks> public static RpcAlpcClientBase CreateClient(RpcServer server, RpcClientBuilderArguments args) { return(CreateClient(server, args, false)); }
/// <summary> /// Create an instance of an RPC client. /// </summary> /// <param name="server">The RPC server to base the client on.</param> /// <param name="ignore_cache">True to ignore cached assemblies.</param> /// <param name="args">Additional builder arguments.</param> /// <returns>The created RPC client.</returns> /// <remarks>This method will cache the results of the compilation against the RpcServer.</remarks> public static RpcAlpcClientBase CreateClient(RpcServer server, RpcClientBuilderArguments args, bool ignore_cache) { return(CreateClient(server, args, ignore_cache, null)); }
/// <summary> /// Create an instance of an RPC client. /// </summary> /// <param name="server">The RPC server to base the client on.</param> /// <param name="ignore_cache">True to ignore cached assemblies.</param> /// <param name="args">Additional builder arguments.</param> /// <param name="provider">Code DOM provider to compile the assembly.</param> /// <returns>The created RPC client.</returns> /// <remarks>This method will cache the results of the compilation against the RpcServer.</remarks> public static RpcAlpcClientBase CreateClient(RpcServer server, RpcClientBuilderArguments args, bool ignore_cache, CodeDomProvider provider) { Type type = BuildAssembly(server, args, ignore_cache, provider ?? new CSharpCodeProvider()).GetTypes().Where(t => typeof(RpcAlpcClientBase).IsAssignableFrom(t)).First(); return((RpcAlpcClientBase)Activator.CreateInstance(type)); }
/// <summary> /// Compile an in-memory assembly for the RPC client. /// </summary> /// <param name="server">The RPC server to base the client on.</param> /// <param name="args">Additional builder arguments.</param> /// <returns>The compiled assembly.</returns> /// <remarks>This method will cache the results of the compilation against the RpcServer.</remarks> public static Assembly BuildAssembly(RpcServer server, RpcClientBuilderArguments args) { return(BuildAssembly(server, args, false)); }
/// <summary> /// Compile an in-memory assembly for the RPC client. /// </summary> /// <param name="server">The RPC server to base the client on.</param> /// <param name="args">Additional builder arguments.</param> /// <param name="ignore_cache">True to ignore cached assemblies.</param> /// <returns>The compiled assembly.</returns> /// <remarks>This method will cache the results of the compilation against the RpcServer.</remarks> public static Assembly BuildAssembly(RpcServer server, RpcClientBuilderArguments args, bool ignore_cache) { return(BuildAssembly(server, args, ignore_cache, new CSharpCodeProvider())); }
/// <summary> /// Build a source file for the RPC client. /// </summary> /// <param name="server">The RPC server to base the client on.</param> /// <param name="args">Additional builder arguments.</param> /// <param name="options">The code genearation options, can be null.</param> /// <param name="provider">The code dom provider, such as CSharpDomProvider</param> /// <returns>The source code file.</returns> public static string BuildSource(RpcServer server, RpcClientBuilderArguments args, CodeDomProvider provider, CodeGeneratorOptions options) { return(GenerateSourceCode(provider, options, new RpcClientBuilder(server, args).Generate())); }