SecureDelete.WipeContext.GetFailedObjectsWithErrors C# (CSharp) Method

GetFailedObjectsWithErrors() public method

Get all failed objects with their associated errors
public GetFailedObjectsWithErrors ( ) : NativeMethods.WError>[].KeyValuePair
return NativeMethods.WError>[].KeyValuePair
        public KeyValuePair<NativeMethods.WSmallObject, NativeMethods.WError>[] GetFailedObjectsWithErrors()
        {
            CheckContextInitialized();
            int number;

            // failed objects can be retrieved only if the context is stopped
            if(_status != ContextStatus.Stopped) {
                throw new Exception("Object can be inserted only when the context is stopped");
            }

            if(GetFailedObjectNumber(out number) == false) {
                return null;
            }

            // get the errors
            List<KeyValuePair<NativeMethods.WSmallObject, NativeMethods.WError>> objects =
                new List<KeyValuePair<NativeMethods.WSmallObject, NativeMethods.WError>>();

            for(int i = 0; i < number; i++) {
                NativeMethods.WSmallObject item = new NativeMethods.WSmallObject();
                NativeMethods.WError error = new NativeMethods.WError();

                if(GetFailedObject(i, out item, true, out error) == false) {
                    // return what we could get so far
                    return objects.ToArray();
                }
                else {
                    KeyValuePair<NativeMethods.WSmallObject, NativeMethods.WError> pair =
                        new KeyValuePair<NativeMethods.WSmallObject, NativeMethods.WError>(item, error);

                    objects.Add(pair);
                }
            }

            // all errors could be retrieved
            return objects.ToArray();
        }