SecureDelete.WipeError.ReadNative C# (CSharp) Method

ReadNative() public method

public ReadNative ( NativeMethods error ) : void
error NativeMethods
return void
        public void ReadNative(NativeMethods.WError error)
        {
            _time = new DateTime(error.time.wYear, error.time.wMonth, error.time.wDay, error.time.wHour,
                                 error.time.wMinute, error.time.wSecond, error.time.wMilliseconds);

            switch(error.severity) {
                case NativeMethods.SEVERITY_HIGH: {
                    _severity = ErrorSeverity.High;
                    break;
                }
                case NativeMethods.SEVERITY_MEDIUM: {
                    _severity = ErrorSeverity.Medium;
                    break;
                }
                case NativeMethods.SEVERITY_LOW: {
                    _severity = ErrorSeverity.Low;
                    break;
                }
            }

            _message = error.message;
        }

Usage Example

Example #1
0
        /// <summary>
        /// Get the category of wipe errors
        /// </summary>
        public List<WipeError> GetWipeErrors()
        {
            List<WipeError> wipeErrors = new List<WipeError>();
            ContextStatus status;
            bool valid = false;
            int count = _beforeWipeErrors.Count;

            // add before wipe errors
            for(int i = 0; i < count; i++) {
                wipeErrors.Add(_beforeWipeErrors[i]);
            }

            if(context.IsOpen) {
                // ensure the context is stopped
                if(context.GetContextStatus(out status)) {
                    if(status == ContextStatus.Stopped) {
                        valid = context.IsInitialized;
                    }
                }

                if(valid) {
                    // get the errors
                    NativeMethods.WError[] errors = context.GetErrors();

                    if(errors != null) {
                        for(int i = 0; i < errors.Length; i++) {
                            WipeError error = new WipeError();
                            error.ReadNative(errors[i]);
                            wipeErrors.Add(error);
                        }
                    }
                }
            }

            // add after wipe errors
            count = _afterWipeErrors.Count;

            for(int i = 0; i < count; i++) {
                wipeErrors.Add(_afterWipeErrors[i]);
            }

            return wipeErrors;
        }