Beispiel #1
0
        //protected override object NewDriveDynamicParameters();
        protected override PSDriveInfo RemoveDrive(PSDriveInfo drive)
        {
            JottacloudPSDriveInfo jedi = null;

            if (drive == null)
            {
                WriteError(new ErrorRecord(new ArgumentNullException("drive"), "NullDrive", ErrorCategory.InvalidArgument, drive));
                return(null);
            }
            else
            {
                // Close the JAFS connection to the drive.
                jedi = drive as JottacloudPSDriveInfo;
                if (jedi == null)
                {
                    WriteError(new ErrorRecord(new ArgumentException("Specified drive is not handled by JottacloudPSProvider"), "InvalidDrive", ErrorCategory.InvalidArgument, drive));
                    return(null);
                }
                else
                {
                    //jedi.JAFS.Close();  // TODO: Currently no persistant connection!
                    return(jedi);
                }
            }
        }
Beispiel #2
0
        //protected override Collection<PSDriveInfo> InitializeDefaultDrives()
        protected override PSDriveInfo NewDrive(PSDriveInfo drive)
        {
            JottacloudPSDriveInfo jedi = null;

            if (drive == null)
            {
                WriteError(new ErrorRecord(new ArgumentNullException("drive"), "NullDrive", ErrorCategory.InvalidArgument, null));
            }
            // Check if the drive root is not null or empty and if it is valid.

            /*else if (String.IsNullOrEmpty(drive.Root))
             * {
             *  WriteError(new ErrorRecord(new ArgumentException("drive.Root"), "NoRoot", ErrorCategory.InvalidArgument, drive));
             *  return null;
             * }*/
            else if (drive.Credential == null)
            {
                WriteError(new ErrorRecord(new ArgumentNullException("drive.Credential"), "NoCredential", ErrorCategory.InvalidArgument, drive));
            }
            else
            {
                // Create a new drive and create an ODBC connection to the new drive.
                jedi = new JottacloudPSDriveInfo(drive);
                Jottacloud jafs = new Jottacloud((NetworkCredential)drive.Credential);
                jafs.ClientMountRoot          = jedi.Name;
                jafs.ClientMountPathSeparator = PSPathSeparator;
                jedi.JAFS = jafs;
            }
            return(jedi);
        }