Esempio n. 1
0
 private RpcClientBuilder(RpcServer server, RpcClientBuilderArguments args)
 {
     _server           = server;
     _type_descriptors = new Dictionary <NdrBaseTypeReference, RpcTypeDescriptor>();
     _args             = args;
     _proc_names       = new HashSet <string>();
 }
Esempio n. 2
0
        /// <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));
        }
Esempio n. 3
0
        /// <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]);
        }
Esempio n. 4
0
 /// <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));
 }
Esempio n. 5
0
 /// <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));
 }
Esempio n. 6
0
        /// <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));
        }
Esempio n. 7
0
 /// <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));
 }
Esempio n. 8
0
 /// <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()));
 }
Esempio n. 9
0
 /// <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()));
 }