Пример #1
0
        internal static Hashtable ConvertCimModuleFileToManifestHashtable(RemoteDiscoveryHelper.CimModuleFile cimModuleFile, string temporaryModuleManifestPath, ModuleCmdletBase cmdlet, ref bool containedErrors)
        {
            Dbg.Assert(cimModuleFile.FileCode == RemoteDiscoveryHelper.CimFileCode.PsdV1, "Caller should verify the file is of the right type");

            ScriptBlockAst scriptBlockAst = null;

            if (!containedErrors)
            {
                System.Management.Automation.Language.Token[] throwAwayTokens;
                ParseError[] parseErrors;
                scriptBlockAst = System.Management.Automation.Language.Parser.ParseInput(cimModuleFile.FileData, temporaryModuleManifestPath, out throwAwayTokens, out parseErrors);
                if ((scriptBlockAst == null) || (parseErrors != null && parseErrors.Length > 0))
                {
                    containedErrors = true;
                }
            }

            Hashtable data = null;

            if (!containedErrors)
            {
                ScriptBlock scriptBlock = new ScriptBlock(scriptBlockAst, isFilter: false);
                data = cmdlet.LoadModuleManifestData(
                    temporaryModuleManifestPath,
                    scriptBlock,
                    ModuleCmdletBase.ModuleManifestMembers,
                    0 /* - don't write errors, don't load elements, don't return null on first error */,
                    ref containedErrors);
            }

            return(data);
        }
Пример #2
0
        internal static Hashtable ConvertCimModuleFileToManifestHashtable(CimModuleFile cimModuleFile, string temporaryModuleManifestPath, ModuleCmdletBase cmdlet, ref bool containedErrors)
        {
            ScriptBlockAst ast = null;

            if (!containedErrors)
            {
                System.Management.Automation.Language.Token[] tokenArray;
                ParseError[] errorArray;
                ast = Parser.ParseInput(cimModuleFile.FileData, temporaryModuleManifestPath, out tokenArray, out errorArray);
                if ((ast == null) || ((errorArray != null) && (errorArray.Length > 0)))
                {
                    containedErrors = true;
                }
            }
            Hashtable hashtable = null;

            if (!containedErrors)
            {
                ScriptBlock scriptBlock = new ScriptBlock(ast, false);
                hashtable = cmdlet.LoadModuleManifestData(temporaryModuleManifestPath, scriptBlock, ModuleCmdletBase.ModuleManifestMembers, 0, ref containedErrors);
            }
            return(hashtable);
        }