protected virtual void Dispose(bool disposing) { if (disposing) { if (m_disposed || m_handle == -1) { throw new ObjectDisposedException(); } lock (m_objects) { for (int i = 0; i < m_objects.Count; i++) { SessionContainer disp = (SessionContainer)m_objects[i]; disp.CloseManaged(true); } m_objects.Clear(); } } //if (m_mechanism.Parameter != null) //{ // Array.Clear(m_mechanism.Parameter, 0, m_mechanism.Parameter.Length); //} if (!m_disposed && m_handle != -1) { Close(); } // this is only added so the compiler wont complain that this member is never used if (m_maxProcessingBytes != 1024) { m_maxProcessingBytes = 1024; } m_disposed = true; m_handle = -1; }
/// <summary> /// Removes a session object reference. /// </summary> /// <param name="obj">The cryptoki object to be dereferenced.</param> internal void RemoveSessionObject(SessionContainer obj) { lock (m_objects) { m_objects.Remove(obj); } }
/// <summary> /// Adds a reference to a cryptoki object opened in the session context. /// </summary> /// <param name="obj">The cryptoki object to be referenced.</param> internal void AddSessionObject(SessionContainer obj) { lock (m_objects) { m_objects.Add(obj); } }