コード例 #1
0
        internal static void CompileStream(SrgsDocument srgsGrammar, string filename, Stream stream, bool fOutputCfg, string[] referencedAssemblies, string keyFile)
        {
            ISrgsParser srgsParser = new SrgsDocumentParser(srgsGrammar.Grammar);
            List <CustomGrammar.CfgResource> cfgResources = new List <CustomGrammar.CfgResource>();
            StringBuilder stringBuilder = new StringBuilder();

            srgsGrammar.Grammar.Validate();
            CultureInfo culture;
            object      obj = CompileStream(1, srgsParser, null, filename, stream, fOutputCfg, stringBuilder, cfgResources, out culture, referencedAssemblies, keyFile);

            if (!fOutputCfg)
            {
                CustomGrammar customGrammar = new CustomGrammar();
                customGrammar.Combine((CustomGrammar)obj, stringBuilder.ToString());
                customGrammar.CreateAssembly(filename, cfgResources);
            }
        }
コード例 #2
0
        /// <summary>
        /// Produces the binary grammar format.
        /// </summary>
        /// <param name="srgsGrammar">Source SRGS XML streams</param>
        /// <param name="filename">filename to compile to</param>
        /// <param name="stream">stream to compile to</param>
        /// <param name="fOutputCfg">Compile for CFG or DLL</param>
        /// <param name="referencedAssemblies">List of referenced assemblies</param>
        /// <param name="keyFile">Strong name</param>
        internal static void CompileStream(SrgsDocument srgsGrammar, string filename, Stream stream, bool fOutputCfg, string[] referencedAssemblies, string keyFile)
        {
            ISrgsParser srgsParser = new SrgsDocumentParser(srgsGrammar.Grammar);

            List <CustomGrammar.CfgResource> cfgResources = new();

            StringBuilder innerCode = new();
            CultureInfo   culture;

            // Validate the grammar before compiling it. Set the tag-format and sapi flags too.
            srgsGrammar.Grammar.Validate();

            object cg = CompileStream(1, srgsParser, null, filename, stream, fOutputCfg, innerCode, cfgResources, out culture, referencedAssemblies, keyFile);

            // Create the DLL if this needs to be done
            if (!fOutputCfg)
            {
                throw new PlatformNotSupportedException();
            }
        }