Example #1
0
        protected override void ProcessRecord()
        {
            var context = RunspaceContext.CurrentThread;
            var source  = context.Source;
            var extent  = new ResourceExtent(
                file: source.File.Path,
                startLineNumber: Body.Ast.Extent.StartLineNumber
                );

            // Create PS instance for execution
            var ps = context.NewPowerShell();

            ps.AddCommand(new CmdletInfo(InvokeCmdletName, typeof(InvokeDocumentCommand)));
            ps.AddParameter(InvokeCmdlet_IfParameter, If);
            ps.AddParameter(InvokeCmdlet_WithParameter, With);
            ps.AddParameter(InvokeCmdlet_BodyParameter, Body);

            var block = new ScriptDocumentBlock(
                source: source.File,
                name: Name,
                body: ps,
                tag: Tag,
                extent: extent
                );

            WriteObject(block);
        }
Example #2
0
        protected override void ProcessRecord()
        {
            var context    = RunspaceContext.CurrentThread;
            var sourceFile = context.SourceFile;
            var extent     = new ResourceExtent(
                file: sourceFile.Path,
                startLineNumber: Body.Ast.Extent.StartLineNumber
                );

            // Create PS instance for execution
            var ps = context.NewPowerShell();

            ps.AddCommand(new CmdletInfo(InvokeBlockCmdletName, typeof(InvokeBlockCommand)));
            //ps.AddParameter(InvokeBlockCmdlet_TypeParameter, NodeType);
            ps.AddParameter(InvokeBlockCmdlet_BodyParameter, Body);

            var block = new ScriptDocumentBlock(
                source: sourceFile,
                name: Name,
                //info: helpInfo,
                body: ps,
                tag: Tag,
                extent: extent
                //type: NodeType
                //dependsOn: RuleHelper.ExpandRuleName(DependsOn, MyInvocation.ScriptName, source.ModuleName),
                //configuration: Configure
                );

            WriteObject(block);
        }
Example #3
0
        protected override void ProcessRecord()
        {
            var context = RunspaceContext.CurrentThread;
            //var metadata = GetMetadata(MyInvocation.ScriptName, MyInvocation.ScriptLineNumber, MyInvocation.OffsetInLine);
            //var tag = GetTag(Tag);
            //var source = context.Source;

            //context.VerboseFoundRule(ruleName: Name, scriptName: MyInvocation.ScriptName);

            //var visitor = new RuleLanguageAst(ruleName: Name, context: context);
            //Body.Ast.Visit(visitor);

            //if (visitor.Errors != null)
            //{
            //    foreach (var errorRecord in visitor.Errors)
            //    {
            //        WriteError(errorRecord: errorRecord);
            //    }
            //}

            //CheckDependsOn();

            var ps = context.NewPowerShell();

            ps.AddCommand(new CmdletInfo(InvokeBlockCmdletName, typeof(InvokeBlockCommand)));
            //ps.AddParameter(InvokeBlockCmdlet_TypeParameter, NodeType);
            ps.AddParameter(InvokeBlockCmdlet_BodyParameter, Body);

            //PipelineContext.EnableLogging(ps);

            var block = new ScriptDocumentBlock(
                source: context.SourceFile,
                name: Name,
                //info: helpInfo,
                body: ps,
                tag: Tag
                //type: NodeType
                //dependsOn: RuleHelper.ExpandRuleName(DependsOn, MyInvocation.ScriptName, source.ModuleName),
                //configuration: Configure
                );

            WriteObject(block);
        }
 internal ScriptDocumentBuilder(ScriptDocumentBlock block)
 {
     _Block = block;
 }
 internal ScriptDocumentBuilder(ScriptDocumentBlock block, IDocumentConvention[] conventions)
 {
     _Block       = block;
     _Conventions = conventions;
 }