private void InitializeProvider(CmdletProvider providerInstance, ProviderInfo provider) { List <PSDriveInfo> drives = new List <PSDriveInfo>(); DriveCmdletProvider driveProvider = providerInstance as DriveCmdletProvider; if (driveProvider != null) { Collection <PSDriveInfo> collection = driveProvider.DoInitializeDefaultDrives(); if ((collection != null) && (collection.Count > 0)) { drives.AddRange(collection); _providersCurrentDrive[provider] = collection[0]; } } if (drives.Count > 0) { foreach (PSDriveInfo driveInfo in drives) { if (driveInfo != null) { // TODO: need to set driveInfo.Root // TODO:this should be automatically called when using DriveIntrinsics.New! #providerSupport driveProvider.DoNewDrive(driveInfo); try { //always to global scope _executionContext.SessionState.Drive.New(driveInfo, SessionStateScope <PSDriveInfo> .ScopeSpecifiers.Global.ToString()); } catch { // TODO: What should we do if the drive name is not unique? // => I guess overwrite the old one and write a warning (however this works from here) } } } } }
private void InitializeProvider(CmdletProvider providerInstance, ProviderInfo provider) { List <PSDriveInfo> drives = new List <PSDriveInfo>(); DriveCmdletProvider driveProvider = providerInstance as DriveCmdletProvider; if (driveProvider != null) { Collection <PSDriveInfo> collection = driveProvider.DoInitializeDefaultDrives(); if ((collection != null) && (collection.Count > 0)) { drives.AddRange(collection); _providersCurrentDrive[provider] = collection[0]; } } if (drives.Count > 0) { foreach (PSDriveInfo driveInfo in drives) { if (driveInfo != null) { // TODO: need to set driveInfo.Root driveProvider.DoNewDrive(driveInfo); try { _drives.Add(driveInfo.Name, driveInfo); } catch { // TODO: What should we do if the drive name is not unique? } } } } }