示例#1
0
        public static string CreateCode(
            Type proxyType,
            ICodeGenerator generator,
            XmlRpcProxyCodeGenOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(
                          "options",
                          "The options parameter cannot be null");
            }

            CodeCompileUnit ccu = CreateCodeCompileUnit(proxyType, generator, options);

            CodeGeneratorOptions cgo = new CodeGeneratorOptions();

            cgo.BlankLinesBetweenMembers = true;
            cgo.BracingStyle             = "C";

            StringWriter sw = new StringWriter(CultureInfo.InvariantCulture);

            generator.GenerateCodeFromCompileUnit(ccu, sw, cgo);

            string ret = sw.ToString();

            return(ret);
        }
示例#2
0
        public static CodeCompileUnit CreateCodeCompileUnit(
            Type proxyType,
            ICodeGenerator generator,
            XmlRpcProxyCodeGenOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(
                          "options",
                          "The options parameter cannot be null");
            }

            // create unique names
            string baseName = proxyType.Name;

            // string leading "I"
            if (baseName.StartsWith("I") == true)
            {
                baseName = baseName.Remove(0, 1);
            }

            string moduleName = String.Format(
                CultureInfo.InvariantCulture,
                "{0}{1}.dll",
                baseName,
                DEFAULT_SUFFIX);

            string assemblyName = "";

            if (options.Namespace.Length > 0)
            {
                assemblyName = options.Namespace;
            }
            else
            {
                assemblyName = String.Format(
                    CultureInfo.InvariantCulture,
                    "{0}{1}",
                    baseName,
                    DEFAULT_SUFFIX);
            }

            string typeName = "";

            if (options.TypeName.Length > 0)
            {
                typeName = options.TypeName;
            }
            else
            {
                typeName = assemblyName;
            }

            bool implicitAsync     = options.ImplicitAsync;
            bool flattenInterfaces = options.FlattenInterfaces;

            CodeCompileUnit ccu = BuildCompileUnit(
                proxyType,
                assemblyName,
                moduleName,
                typeName,
                implicitAsync,
                flattenInterfaces);

            return(ccu);
        }
        public static string CreateCode(
            Type proxyType,
            ICodeGenerator generator,
            XmlRpcProxyCodeGenOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(
                    "options",
                    "The options parameter cannot be null");
            }

            CodeCompileUnit ccu = CreateCodeCompileUnit(proxyType, generator, options);

            CodeGeneratorOptions cgo = new CodeGeneratorOptions();
            cgo.BlankLinesBetweenMembers = true;
            cgo.BracingStyle = "C";

            StringWriter sw = new StringWriter(CultureInfo.InvariantCulture);

            generator.GenerateCodeFromCompileUnit(ccu, sw, cgo);

            string ret = sw.ToString();

            return ret;
        }
        public static CodeCompileUnit CreateCodeCompileUnit(
            Type proxyType,
            ICodeGenerator generator,
            XmlRpcProxyCodeGenOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(
                    "options",
                    "The options parameter cannot be null");
            }

            // create unique names
            string baseName = proxyType.Name;

            // string leading "I"
            if (baseName.StartsWith("I") == true)
            {
                baseName = baseName.Remove(0,1);
            }

            string moduleName = String.Format(
                CultureInfo.InvariantCulture,
                "{0}{1}.dll",
                baseName,
                DEFAULT_SUFFIX);

            string assemblyName = "";
            if (options.Namespace.Length > 0)
            {
                assemblyName = options.Namespace;
            }
            else
            {
                assemblyName = String.Format(
                    CultureInfo.InvariantCulture,
                    "{0}{1}",
                    baseName,
                    DEFAULT_SUFFIX);
            }

            string typeName = "";
            if (options.TypeName.Length > 0)
            {
                typeName = options.TypeName;
            }
            else
            {
                typeName = assemblyName;
            }

            bool implicitAsync = options.ImplicitAsync;
            bool flattenInterfaces = options.FlattenInterfaces;

            CodeCompileUnit ccu = BuildCompileUnit(
                proxyType,
                assemblyName,
                moduleName,
                typeName,
                implicitAsync,
                flattenInterfaces);

            return ccu;
        }