Inheritance: System.Management.Automation.PSDriveInfo
Ejemplo n.º 1
0
        // 20120824
//        protected override PSDriveInfo NewDrive(PSDriveInfo drive)
//        {
//            try{
//                WriteVerbose("UiaProvider::NewDrive()");
//                string windowName = string.Empty;
//                string processName = string.Empty;
//                int processId = 0;
//
//                RuntimeDefinedParameterDictionary dynamicParameters =
//                    base.DynamicParameters as RuntimeDefinedParameterDictionary;
//                try{windowName = dynamicParameters["WindowName"].Value.ToString();}
//                catch (Exception e1) {
//                    // nothing to report
//                    // there might not be a parameter
//                }
//                try{processName = dynamicParameters["ProcessName"].Value.ToString();}
//                catch (Exception e2) {
//                    // nothing to report
//                    // there might not be a parameter
//                }
//                try{processId = (int)dynamicParameters["ProcessId"].Value;}
//                catch (Exception e3) {
//                    // nothing to report
//                    // there might not be a parameter
//                }
//                if (processId > 0) {
//                    return new UiaDriveInfo(processId, drive);
//                } else if (processName.Length > 0) {
//                    return new UiaDriveInfo(processName, drive);
//                } else if (windowName.Length > 0) {
//                    return new UiaDriveInfo(windowName, drive);
//                } else {
//                    return new UiaDriveInfo(drive);
//                }
//            }
//            catch (Exception e) {
//                WriteVerbose(e.Message);
//                WriteVerbose("UiaProvider::NewDrive()");
//                return null;
//            }
//        }

        /// <summary>
        /// The Windows PowerShell engine calls this method when the
        /// Remove-PSDrive cmdlet is run and the path to this provider is
        /// specified. This method closes the ODBC connection of the drive.
        /// </summary>
        /// <param name="drive">The drive to remove.</param>
        /// <returns>An accessDBPSDriveInfo object that represents
        /// the removed drive.</returns>
        protected override PSDriveInfo RemoveDrive(PSDriveInfo drive)
        {
            try{
                // Check if drive object is null.
                if (drive == null)
                {
                    ErrorRecord err =
                        new ErrorRecord(
                            new ArgumentNullException("drive"),
                            "NullDrive",
                            ErrorCategory.InvalidArgument,
                            null);
                    err.ErrorDetails =
                        new ErrorDetails(
                            "The PSDriveInfo argument is null");
                    //ThrowTerminatingError(err);
                    ThrowTerminatingError(err);

                    // TODO
                    // this.WriteError();
                }

                UiaDriveInfo driveInfo = drive as UiaDriveInfo;

                if (driveInfo == null)
                {
                    return(null);
                }

                driveInfo.Window = null;

                return(driveInfo);
            }
            catch (Exception e) {
                WriteVerbose(e.Message);
                WriteVerbose("UiaProvider::RemoveDrive()");
                return(null);
            }
        } // End RemoveDrive.
Ejemplo n.º 2
0
 protected override Collection <PSDriveInfo> InitializeDefaultDrives()
 {
     NewDriveDynamicParameters();
     try{
         Collection <PSDriveInfo> result = new Collection <PSDriveInfo>();
         PSDriveInfo drive =
             new PSDriveInfo(
                 "UIA",
                 ProviderInfo,
                 @"UIAutomation\UiaProvider::\", //"UIAutomation",
                 "This is the UI Automation root drive",
                 null);
         _rootDrive = new UiaDriveInfo(drive);
         result.Add(_rootDrive);
         return(result);
     }
     catch (Exception e) {
         WriteVerbose(e.Message);
         WriteVerbose("UiaProvider::InitializeDefaultDrives()");
         return(null);
     }
 }
Ejemplo n.º 3
0
 protected override void Stop()
 {
     _rootDrive = null;
 }
Ejemplo n.º 4
0
 protected override Collection<PSDriveInfo> InitializeDefaultDrives()
 {
     NewDriveDynamicParameters();
     try{
         Collection<PSDriveInfo> result = new Collection<PSDriveInfo>();
         PSDriveInfo drive =
             new PSDriveInfo(
                 "UIA",
                 ProviderInfo,
                 @"UIAutomation\UiaProvider::\", //"UIAutomation",
                 "This is the UI Automation root drive",
                 null);
         _rootDrive = new UiaDriveInfo(drive);
         result.Add(_rootDrive);
         return result;
     }
     catch (Exception e) {
         WriteVerbose(e.Message);
         WriteVerbose("UiaProvider::InitializeDefaultDrives()");
         return null;
     }
 }
Ejemplo n.º 5
0
 protected override void Stop()
 {
     _rootDrive = null;
 }