本文整理汇总了C#中System.Management.Automation.PSDriveInfo类的典型用法代码示例。如果您正苦于以下问题:C# PSDriveInfo类的具体用法?C# PSDriveInfo怎么用?C# PSDriveInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PSDriveInfo类属于System.Management.Automation命名空间,在下文中一共展示了PSDriveInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VirtualDiskPSDriveInfo
public VirtualDiskPSDriveInfo(PSDriveInfo toCopy, string root, VirtualDisk disk)
: base(toCopy.Name, toCopy.Provider, root, toCopy.Description, toCopy.Credential)
{
_disk = disk;
_volMgr = new VolumeManager(_disk);
_fsCache = new Dictionary<string, DiscFileSystem>();
}
示例2: ProcessRecord
protected override void ProcessRecord()
{
var provider = SessionState.Provider.GetOne(PSProvider);
var driveInfo = new PSDriveInfo(Name, provider, Root, Description, Credential);
var realDrive = SessionState.Drive.New(driveInfo, Scope ?? "local", ProviderRuntime);
WriteObject(realDrive);
}
示例3: NewDrive
protected override PSDriveInfo NewDrive(PSDriveInfo drive)
{
if (drive == null)
{
WriteError(new ErrorRecord(
new ArgumentNullException("drive"),
"NullDrive",
ErrorCategory.InvalidArgument,
null));
return null;
}
SFGAO attributes;
SFGAO isContainerQuery = SFGAO.Browsable | SFGAO.Folder;
IdList pidl = GetPidlFromPath(drive.Root, isContainerQuery, out attributes);
if ((attributes & isContainerQuery) == SFGAO.None)
{
WriteError(new ErrorRecord(
new ArgumentException("drive.Root"),
"NotAContainer",
ErrorCategory.InvalidArgument,
null));
return null;
}
return new ShellPSDriveInfo((ShellFolder)ShellItem.GetShellItem(pidl, new ShellItem.ShellItemKnownInfo()
{
LoadedAttributes = isContainerQuery,
Attributes = attributes
}), drive);
}
示例4: ProviderInfo
internal ProviderInfo(SessionState sessionState, Type implementingType, string name, string description, string home, string helpFile, PSSnapInInfo psSnapIn)
{
this.helpFile = "";
if (sessionState == null)
{
throw PSTraceSource.NewArgumentNullException("sessionState");
}
if (implementingType == null)
{
throw PSTraceSource.NewArgumentNullException("implementingType");
}
if (string.IsNullOrEmpty(name))
{
throw PSTraceSource.NewArgumentException("name");
}
if (string.IsNullOrEmpty(name))
{
throw PSTraceSource.NewArgumentException("name");
}
this.sessionState = sessionState;
this.name = name;
this.description = description;
this.home = home;
this.implementingType = implementingType;
this.helpFile = helpFile;
this.pssnapin = psSnapIn;
this.hiddenDrive = new PSDriveInfo(this.FullName, this, "", "", null);
this.hiddenDrive.Hidden = true;
}
示例5: InitializeDefaultDrives
protected override Collection<PSDriveInfo> InitializeDefaultDrives()
{
PSDriveInfo item = new PSDriveInfo("Env", ProviderInfo, string.Empty, string.Empty, null);
Collection<PSDriveInfo> collection = new Collection<PSDriveInfo>();
collection.Add(item);
return collection;
}
示例6: UpdatableHelpSystemDrive
internal UpdatableHelpSystemDrive(PSCmdlet cmdlet, string path, PSCredential credential)
{
for (int i = 0; i < 6; i++)
{
this._driveName = Path.GetFileNameWithoutExtension(Path.GetRandomFileName());
this._cmdlet = cmdlet;
if (path.EndsWith(@"\", StringComparison.OrdinalIgnoreCase) || path.EndsWith("/", StringComparison.OrdinalIgnoreCase))
{
path = path.Remove(path.Length - 1);
}
PSDriveInfo atScope = cmdlet.SessionState.Drive.GetAtScope(this._driveName, "local");
if (atScope != null)
{
if (atScope.Root.Equals(path))
{
return;
}
if (i < 5)
{
continue;
}
cmdlet.SessionState.Drive.Remove(this._driveName, true, "local");
}
atScope = new PSDriveInfo(this._driveName, cmdlet.SessionState.Internal.GetSingleProvider("FileSystem"), path, string.Empty, credential);
cmdlet.SessionState.Drive.New(atScope, "local");
return;
}
}
示例7: RemoveDrive
protected virtual PSDriveInfo RemoveDrive(PSDriveInfo drive)
{
using (PSTransactionManager.GetEngineProtectionScope())
{
return drive;
}
}
示例8: DriveInfo
public DriveInfo(PSDriveInfo driveInfo, NewDriveParameters parameters)
: base(driveInfo)
{
if (parameters != null)
Directory = parameters.Directory;
EnsureDescription();
}
示例9: PathInfo
internal PathInfo(PSDriveInfo drive, ProviderInfo provider, Path path, SessionState sessionState)
{
Drive = drive;
Provider = provider;
_path = path;
_sessionState = sessionState;
}
示例10: InitializeNewDrive
/// <summary>
/// Initializes the specified VFS drive.
/// </summary>
/// <param name="drive">The drive to initialize.</param>
/// <returns>The <see cref="VfsDriveInfo"/> object which represents the initialized drive.</returns>
protected override VfsDriveInfo InitializeNewDrive(PSDriveInfo drive)
{
if (drive is OrchardDriveInfo)
{
return (VfsDriveInfo)drive;
}
var driveParameters = (OrchardDriveParameters)DynamicParameters;
if (driveParameters == null)
{
return null;
}
if (!OrchardPsSnapIn.VerifyOrchardDirectory(driveParameters.OrchardRoot))
{
this.WriteError(
ThrowHelper.InvalidRootPathException(driveParameters.OrchardRoot),
ErrorIds.InvalidRootDirectory,
ErrorCategory.InvalidArgument,
drive);
return null;
}
VfsDriveInfo orchardDrive = null;
this.TryCritical(
() => orchardDrive = this.InitializeOrchardDrive(drive, driveParameters),
ErrorIds.OrchardInitFailed,
ErrorCategory.OpenError);
return orchardDrive;
}
示例11: RemoveDrive
// NewDrive
/// <summary>
/// Removes a drive from the provider.
/// </summary>
/// <param name = "drive">The drive to remove.</param>
/// <returns>The drive removed.</returns>
protected override PSDriveInfo RemoveDrive(PSDriveInfo drive)
{
// check if drive object is null
if (drive == null)
{
WriteError(new ErrorRecord(
new ArgumentNullException("drive"),
"NullDrive",
ErrorCategory.InvalidArgument,
drive)
);
return null;
}
// dispose database on drive
var ravenDBPSDriveInfo = drive as RavenDBPSDriveInfo;
if (ravenDBPSDriveInfo == null)
{
return null;
}
ravenDBPSDriveInfo.Database.Dispose();
return ravenDBPSDriveInfo;
}
示例12: CompareTo
public int CompareTo(PSDriveInfo drive)
{
if (drive == null)
{
throw PSTraceSource.NewArgumentNullException("drive");
}
return string.Compare(this.Name, drive.Name, true, CultureInfo.CurrentCulture);
}
示例13: InitializeDefaultDrives
protected override Collection<PSDriveInfo> InitializeDefaultDrives()
{
PSDriveInfo drive = new PSDriveInfo("Objects", this.ProviderInfo, @"\", "Object Manager Root Directory", null);
PSDriveInfo session = new PSDriveInfo("SessionObjects", this.ProviderInfo,
String.Format(@"\Sessions\{0}\BaseNamedObjects", Process.GetCurrentProcess().SessionId), "Current Session Objects", null);
Collection<PSDriveInfo> drives = new Collection<PSDriveInfo>() { drive, session };
return drives;
}
开发者ID:CaledoniaProject,项目名称:sandbox-attacksurface-analysis-tools,代码行数:8,代码来源:ObjectManagerProvider.cs
示例14: NewDrive
protected override PSDriveInfo NewDrive(PSDriveInfo drive)
{
if( drive is DTEDrive )
{
return drive;
}
return new DTEDrive( drive, DTE2 );
}
示例15: NewDrive
internal PSDriveInfo NewDrive(PSDriveInfo drive, CmdletProviderContext context)
{
base.Context = context;
if (((drive.Credential != null) && (drive.Credential != PSCredential.Empty)) && !CmdletProviderManagementIntrinsics.CheckProviderCapabilities(ProviderCapabilities.Credentials, base.ProviderInfo))
{
throw PSTraceSource.NewNotSupportedException("SessionStateStrings", "NewDriveCredentials_NotSupported", new object[0]);
}
return this.NewDrive(drive);
}