private OrchardDriveInfo InitializeOrchardDrive(PSDriveInfo drive, OrchardDriveParameters driveParameters) { this.Console.WriteVerbose("Initializing Orchard session. (This might take a few seconds...)"); this.Console.WriteLine(); ILifetimeScope lifetimeScope = OrchardProviderInfo.Container.BeginLifetimeScope(); var orchardDrive = lifetimeScope.Resolve <OrchardDriveInfo>( new NamedParameter("driveInfo", drive), new NamedParameter("orchardRoot", driveParameters.OrchardRoot)); orchardDrive.Initialize(); var color = System.Console.ForegroundColor; System.Console.ForegroundColor = ConsoleColor.White; System.Console.WriteLine(" Welcome to Orchard PowerShell!"); System.Console.ForegroundColor = color; System.Console.WriteLine(); System.Console.WriteLine( "To get a list of all Orchard-related cmdlets, type Get-OrchardPsCommand -All."); System.Console.WriteLine( "To get a list of all supported cmdlets for the current location type Get-OrchardPsCommand."); System.Console.WriteLine( "To get help about a specific cmdlet, type Get-Help CommandName."); System.Console.WriteLine( "To get more help about the Orchard PowerShell provider, type Get-Help Orchard."); System.Console.WriteLine(); return(orchardDrive); }
/// <summary> /// Gives the provider the ability to map drives after initialization. /// </summary> /// <returns> /// A collection of <see cref="PSDriveInfo"/> objects for each drive the provider wants to mount. If no drives /// should be mounted, an empty collection should be returned. /// </returns> protected override Collection <PSDriveInfo> InitializeDefaultDrives() { var drives = new Collection <PSDriveInfo>(); this.Try( () => { Assembly entryAssembly = Assembly.GetEntryAssembly(); string path = entryAssembly != null ? entryAssembly.Location : Environment.CurrentDirectory; for (var di = new DirectoryInfo(path); di != null; di = di.Parent) { if (OrchardPsSnapIn.VerifyOrchardDirectory(di.FullName)) { var drive = new PSDriveInfo("Orchard", ProviderInfo, "\\", "Orchard drive", Credential); var driveParameters = new OrchardDriveParameters { OrchardRoot = di.FullName }; drives.Add(InitializeOrchardDrive(drive, driveParameters)); break; } } }, ErrorIds.DefaultDrivesInitFailed, ErrorCategory.OpenError); return(drives); }
private OrchardDriveInfo InitializeOrchardDrive(PSDriveInfo drive, OrchardDriveParameters driveParameters) { this.Console.WriteVerbose("Initializing Orchard session. (This might take a few seconds...)"); this.Console.WriteLine(); ILifetimeScope lifetimeScope = OrchardProviderInfo.Container.BeginLifetimeScope(); var orchardDrive = lifetimeScope.Resolve<OrchardDriveInfo>( new NamedParameter("driveInfo", drive), new NamedParameter("orchardRoot", driveParameters.OrchardRoot)); orchardDrive.Initialize(); var color = System.Console.ForegroundColor; System.Console.ForegroundColor = ConsoleColor.White; System.Console.WriteLine(" Welcome to Orchard PowerShell!"); System.Console.ForegroundColor = color; System.Console.WriteLine(); System.Console.WriteLine( "To get a list of all Orchard-related cmdlets, type Get-OrchardPsCommand -All."); System.Console.WriteLine( "To get a list of all supported cmdlets for the current location type Get-OrchardPsCommand."); System.Console.WriteLine( "To get help about a specific cmdlet, type Get-Help CommandName."); System.Console.WriteLine( "To get more help about the Orchard PowerShell provider, type Get-Help Orchard."); System.Console.WriteLine(); return orchardDrive; }
/// <summary> /// Gives the provider the ability to map drives after initialization. /// </summary> /// <returns> /// A collection of <see cref="PSDriveInfo"/> objects for each drive the provider wants to mount. If no drives /// should be mounted, an empty collection should be returned. /// </returns> protected override Collection<PSDriveInfo> InitializeDefaultDrives() { var drives = new Collection<PSDriveInfo>(); this.Try( () => { Assembly entryAssembly = Assembly.GetEntryAssembly(); string path = entryAssembly != null ? entryAssembly.Location : Environment.CurrentDirectory; for (var di = new DirectoryInfo(path); di != null; di = di.Parent) { if (OrchardPsSnapIn.VerifyOrchardDirectory(di.FullName)) { var drive = new PSDriveInfo("Orchard", ProviderInfo, "\\", "Orchard drive", Credential); var driveParameters = new OrchardDriveParameters { OrchardRoot = di.FullName }; drives.Add(InitializeOrchardDrive(drive, driveParameters)); break; } } }, ErrorIds.DefaultDrivesInitFailed, ErrorCategory.OpenError); return drives; }