当前位置: 首页>>代码示例>>C#>>正文


C# PSDriveInfo.Trace方法代码示例

本文整理汇总了C#中System.Management.Automation.PSDriveInfo.Trace方法的典型用法代码示例。如果您正苦于以下问题:C# PSDriveInfo.Trace方法的具体用法?C# PSDriveInfo.Trace怎么用?C# PSDriveInfo.Trace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Management.Automation.PSDriveInfo的用法示例。


在下文中一共展示了PSDriveInfo.Trace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetProviderSpecificPath

 private string GetProviderSpecificPath(PSDriveInfo drive, string workingPath, CmdletProviderContext context)
 {
     if (drive == null)
     {
         throw PSTraceSource.NewArgumentNullException("drive");
     }
     if (workingPath == null)
     {
         throw PSTraceSource.NewArgumentNullException("workingPath");
     }
     drive.Trace();
     tracer.WriteLine("workingPath = {0}", new object[] { workingPath });
     string root = drive.Root;
     try
     {
         root = this.sessionState.Internal.MakePath(drive.Provider, root, workingPath, context);
     }
     catch (NotSupportedException)
     {
     }
     return root;
 }
开发者ID:nickchal,项目名称:pash,代码行数:22,代码来源:LocationGlobber.cs

示例2: NewDrive

 protected override PSDriveInfo NewDrive(PSDriveInfo drive)
 {
     if (drive == null)
     {
         throw PSTraceSource.NewArgumentNullException("drive");
     }
     if (string.IsNullOrEmpty(drive.Root))
     {
         throw PSTraceSource.NewArgumentException("drive.Root");
     }
     if (drive.Persist && !NativeMethods.PathIsNetworkPath(drive.Root))
     {
         ErrorRecord errorRecord = new ErrorRecord(new NotSupportedException(FileSystemProviderStrings.PersistNotSupported), "DriveRootNotNetworkPath", ErrorCategory.InvalidArgument, drive);
         base.ThrowTerminatingError(errorRecord);
     }
     if (this.ShouldMapNetworkDrive(drive))
     {
         this.MapNetworkDrive(drive);
     }
     bool flag = true;
     PSDriveInfo info = null;
     try
     {
         DriveInfo info2 = new DriveInfo(Path.GetPathRoot(drive.Root));
         if (info2.DriveType != DriveType.Fixed)
         {
             flag = false;
         }
     }
     catch (ArgumentException)
     {
     }
     bool flag2 = true;
     if (flag)
     {
         try
         {
             flag2 = NativeDirectoryExists(drive.Root);
         }
         catch (UnauthorizedAccessException)
         {
         }
     }
     if (flag2)
     {
         info = drive;
     }
     else
     {
         Exception exception = new IOException(StringUtil.Format(FileSystemProviderStrings.DriveRootError, drive.Root));
         base.WriteError(new ErrorRecord(exception, "DriveRootError", ErrorCategory.ReadError, drive));
     }
     drive.Trace();
     return info;
 }
开发者ID:nickchal,项目名称:pash,代码行数:55,代码来源:FileSystemProvider.cs

示例3: GetProviderSpecificPath

        /// <summary>
        /// Uses the drive and a relative working path to construct
        /// a string which has a fully qualified provider specific path
        /// </summary>
        /// 
        /// <param name="drive">
        /// The drive to use as the root of the path.
        /// </param>
        /// 
        /// <param name="workingPath">
        /// The relative working directory to the specified drive.
        /// </param>
        /// 
        /// <param name="context">
        /// The context which the core command is running.
        /// </param>
        /// 
        /// <returns>
        /// A string which is contains the fully qualified path in provider
        /// specific form.
        /// </returns>
        /// 
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="drive"/> or <paramref name="workingPath"/> is null.
        /// </exception>
        /// 
        /// <exception cref="ProviderInvocationException">
        /// If the provider throws an exception when its MakePath gets
        /// called.
        /// </exception>
        /// 
        private string GetProviderSpecificPath(
            PSDriveInfo drive,
            string workingPath,
            CmdletProviderContext context)
        {
            if (drive == null)
            {
                throw PSTraceSource.NewArgumentNullException("drive");
            }

            if (workingPath == null)
            {
                throw PSTraceSource.NewArgumentNullException("workingPath");
            }

            // Trace the inputs

            drive.Trace();
            s_tracer.WriteLine(
                "workingPath = {0}",
                workingPath);

            string result = drive.Root;

            try
            {
                result =
                    _sessionState.Internal.MakePath(
                        drive.Provider,
                        result,
                        workingPath,
                        context);
            }
            catch (NotSupportedException)
            {
                // This is valid if the provider doesn't support MakePath.  The
                // drive should be enough.
            }

            return result;
        } // GetProviderSpecificPath
开发者ID:40a,项目名称:PowerShell,代码行数:72,代码来源:LocationGlobber.cs

示例4: NewDrive

        } // Start

        #endregion CmdletProvider members

        #region DriveCmdletProvider members

        /// <summary>
        /// Determines if the specified drive can be mounted.
        /// </summary>
        /// 
        /// <param name="drive">
        /// The drive that is going to be mounted.
        /// </param>
        /// 
        /// <returns>
        /// The same drive that was passed in, if the drive can be mounted.
        /// null if the drive cannot be mounted.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        /// drive is null.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// drive root is null or empty.
        /// </exception>
        protected override PSDriveInfo NewDrive(PSDriveInfo drive)
        {
            // verify parameters

            if (drive == null)
            {
                throw PSTraceSource.NewArgumentNullException("drive");
            }

            if (String.IsNullOrEmpty(drive.Root))
            {
                throw PSTraceSource.NewArgumentException("drive.Root");
            }

            // -Persist switch parameter is supported only for Network paths.
            if (drive.Persist && !PathIsNetworkPath(drive.Root))
            {
                ErrorRecord er = new ErrorRecord(new NotSupportedException(FileSystemProviderStrings.PersistNotSupported), "DriveRootNotNetworkPath", ErrorCategory.InvalidArgument, drive);
                ThrowTerminatingError(er);
            }

            if (IsNetworkMappedDrive(drive))
            {
                // MapNetworkDrive facilitates to map the newly 
                // created PS Drive to a network share.
                this.MapNetworkDrive(drive);
            }

            // The drive is valid if the item exists or the
            // drive is not a fixed drive.  We want to allow
            // a drive to exist for floppies and other such\
            // removable media, even if the media isn't in place.

            bool driveIsFixed = true;
            PSDriveInfo result = null;

            try
            {
                // See if the drive is a fixed drive.
                string pathRoot = Path.GetPathRoot(drive.Root);
                DriveInfo driveInfo = new DriveInfo(pathRoot);

                if (driveInfo.DriveType != DriveType.Fixed)
                {
                    driveIsFixed = false;
                }

                // The current drive is a network drive.
                if (driveInfo.DriveType == DriveType.Network)
                {
                    drive.IsNetworkDrive = true;
                }
            }
            catch (ArgumentException) // swallow ArgumentException incl. ArgumentNullException
            {
            }

            bool validDrive = true;

            if (driveIsFixed)
            {
                // Since the drive is fixed, ensure the root is valid.
                try
                {
                    validDrive = Utils.NativeDirectoryExists(drive.Root);
                }
                catch (IOException)
                {
                    // Ignore, the network path may not be found.
                }
                catch (UnauthorizedAccessException)
                {
                    // Ignore, we may be running in an AppContainer
                }
            }

//.........这里部分代码省略.........
开发者ID:dfinke,项目名称:powershell,代码行数:101,代码来源:FileSystemProvider.cs


注:本文中的System.Management.Automation.PSDriveInfo.Trace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。