Пример #1
0
 /// <summary>
 /// This constructor takes script class properties' values that could have been passed in by the calling internal methods.
 /// </summary>
 public PSScriptFileInfo(
     PSScriptMetadata scriptMetadataComment,
     PSScriptHelp scriptHelpComment,
     PSScriptRequires scriptRequiresComment,
     PSScriptContents scriptRemainingContent
     )
 {
     ScriptMetadataComment = scriptMetadataComment;
     ScriptHelpComment     = scriptHelpComment;
     ScriptRequiresComment = scriptRequiresComment;
     ScriptContent         = scriptRemainingContent;
 }
Пример #2
0
        /// <summary>
        /// Populates script info classes (PSScriptMetadata, PSScriptHelp, PSScriptRequires, PSScriptContents) with previosuly
        /// parsed metadata from the ps1 file.
        /// </summary>
        internal static bool TryPopulateScriptClassesWithParsedContent(
            List <string> psScriptInfoCommentContent,
            List <string> helpInfoCommentContent,
            List <string> requiresCommentContent,
            string[] remainingFileContent,
            out PSScriptMetadata currentMetadata,
            out PSScriptHelp currentHelpInfo,
            out PSScriptRequires currentRequiresComment,
            out PSScriptContents currentEndOfFileContents,
            out ErrorRecord[] errors,
            out string[] verboseMsgs)
        {
            List <ErrorRecord> errorsList = new List <ErrorRecord>();

            bool parsedContentSuccessfully = true;

            currentMetadata = new PSScriptMetadata();
            if (!currentMetadata.ParseContentIntoObj(
                    commentLines: psScriptInfoCommentContent.ToArray(),
                    out ErrorRecord[] metadataErrors,
                    out verboseMsgs))
            {
                errorsList.AddRange(metadataErrors);
                parsedContentSuccessfully = false;
            }

            currentHelpInfo = new PSScriptHelp();
            if (!currentHelpInfo.ParseContentIntoObj(
                    commentLines: helpInfoCommentContent.ToArray(),
                    out ErrorRecord helpError))
            {
                errorsList.Add(helpError);
                parsedContentSuccessfully = false;
            }

            currentRequiresComment = new PSScriptRequires();
            if (!currentRequiresComment.ParseContentIntoObj(
                    commentLines: requiresCommentContent.ToArray(),
                    out ErrorRecord[] requiresErrors))
            {
                errorsList.AddRange(requiresErrors);
                parsedContentSuccessfully = false;
            }

            currentEndOfFileContents = new PSScriptContents();
            currentEndOfFileContents.ParseContent(commentLines: remainingFileContent);

            errors = errorsList.ToArray();
            return(parsedContentSuccessfully);
        }
Пример #3
0
        /// <summary>
        /// This constructor takes metadata values that could have been passed in by the calling cmdlet
        /// and uses those to create associated script class properties (PSScriptMetadata, PSScriptHelp, PSScriptRequires, PSScriptContents)
        /// </summary>
        public PSScriptFileInfo(
            string version,
            Guid guid,
            string author,
            string companyName,
            string copyright,
            string[] tags,
            Uri licenseUri,
            Uri projectUri,
            Uri iconUri,
            ModuleSpecification[] requiredModules,
            string[] externalModuleDependencies,
            string[] requiredScripts,
            string[] externalScriptDependencies,
            string releaseNotes,
            string privateData,
            string description)
        {
            PSScriptMetadata scriptMetadataComment = new PSScriptMetadata(
                version,
                guid,
                author,
                companyName,
                copyright,
                tags,
                licenseUri,
                projectUri,
                iconUri,
                externalModuleDependencies,
                requiredScripts,
                externalScriptDependencies,
                releaseNotes,
                privateData);

            PSScriptHelp     scriptHelpComment      = new PSScriptHelp(description);
            PSScriptRequires scriptRequiresComment  = new PSScriptRequires(requiredModules);
            PSScriptContents scriptRemainingContent = new PSScriptContents(Utils.EmptyStrArray);

            ScriptMetadataComment = scriptMetadataComment;
            ScriptHelpComment     = scriptHelpComment;
            ScriptRequiresComment = scriptRequiresComment;
            ScriptContent         = scriptRemainingContent;
        }