Hello,
I would like to implement a form application which is hosting a PSHost and executes own cmdlets. As far as this it is no Problem.
But my form is using also other dlls and has instanciated objects from these dlls. Now I would like to access this methods from within my cmdlets.
How can this be done?
I will try to explain it with the following code snippets.
First the code implementing the form which is running the PSHost.
namespaceMyApp{classMyAppForm{MyObject obj =newMyObject();// this is the object I want to access later
PSHost pshost =newPSHost();Runspace space; space =RunspaceFactory.CreateRunspace(pshost); space.Open();Pipeline pipeline = space.CreatePipeline(<myCmdlet>);Collection<PSObject> results = pipeline.Invoke();}}
And here is the cmdlet were I would like to access a method from within my form app.
namespaceMyCmdlets{[Cmdlet(VerbsCommon.Verb,"Noun")]publicclassVerb_Noun:Cmdlet// parameters// overridesprotectedoverridevoidBeginProcessing(){// how can I get access to <obj> here? }}
Thanks
Alex