private Runspace GetRunspace() { if (_Runspace == null) { // Get session state var state = HostState.CreateSessionState(); state.LanguageMode = Pipeline.LanguageMode == LanguageMode.FullLanguage ? PSLanguageMode.FullLanguage : PSLanguageMode.ConstrainedLanguage; _Runspace = RunspaceFactory.CreateRunspace(state); if (Runspace.DefaultRunspace == null) { Runspace.DefaultRunspace = _Runspace; } _Runspace.Open(); _Runspace.SessionStateProxy.PSVariable.Set(new HostState.PSDocsVariable()); _Runspace.SessionStateProxy.PSVariable.Set(new HostState.InstanceNameVariable()); _Runspace.SessionStateProxy.PSVariable.Set(new HostState.TargetObjectVariable()); _Runspace.SessionStateProxy.PSVariable.Set(new HostState.InputObjectVariable()); _Runspace.SessionStateProxy.PSVariable.Set(new HostState.DocumentVariable()); _Runspace.SessionStateProxy.PSVariable.Set("ErrorActionPreference", ActionPreference.Continue); _Runspace.SessionStateProxy.PSVariable.Set("WarningPreference", ActionPreference.Continue); _Runspace.SessionStateProxy.PSVariable.Set("VerbosePreference", ActionPreference.Continue); _Runspace.SessionStateProxy.PSVariable.Set("DebugPreference", ActionPreference.Continue); _Runspace.SessionStateProxy.Path.SetLocation(PSDocumentOption.GetWorkingPath()); } return(_Runspace); }
public static PSDocsContext Create(PSDocumentOption option, string[] name, string[] tag, string outputPath) { var actualPath = outputPath; if (!Path.IsPathRooted(actualPath)) { actualPath = Path.Combine(PSDocumentOption.GetWorkingPath(), outputPath); } return(new PSDocsContext { Option = option, Filter = DocumentFilter.Create(name, tag), OutputPath = actualPath }); }
public void InputPath(string[] path) { if (path == null || path.Length == 0) { return; } var basePath = PSDocumentOption.GetWorkingPath(); var filter = PathFilterBuilder.Create(basePath, Option.Input.PathIgnore); filter.UseGitIgnore(); var builder = new InputPathBuilder(Writer, basePath, "*", filter.Build()); builder.Add(path); _InputPath = builder.Build(); }
public static Include Include(string baseDirectory, string culture, string fileName, bool useCulture) { var absolutePath = Path.IsPathRooted(fileName) ? fileName : Path.Combine(baseDirectory, (useCulture ? culture : string.Empty), fileName); if (!Path.IsPathRooted(absolutePath)) { absolutePath = Path.Combine(PSDocumentOption.GetWorkingPath(), absolutePath); } if (!File.Exists(absolutePath)) { throw new FileNotFoundException("The included file was not found.", absolutePath); } return(new Include { Path = absolutePath }); }