/// <summary> /// Indexer that returns sk_value() or calls sk_insert() /// </summary> /// <param name="index"></param> /// <returns></returns> public T this[int index] { get { // Get the native pointer from the stack IntPtr ptr = Native.ExpectNonNull(Native.sk_value(this.ptr, index)); // Create a new object T item = CreateInstance(ptr); // Addref the object item.AddRef(); // Return the managed object return(item); } set { // Insert the item in the stack int ret = Native.sk_insert(this.ptr, value.Handle, index); if (ret < 0) { throw new OpenSslException(); } // Addref the native pointer value.AddRef(); } }
/// <summary> /// Calls sk_insert() /// </summary> /// <param name="index"></param> /// <param name="item"></param> public void Insert(int index, T item) { // Insert the item into the stack Native.ExpectSuccess(Native.sk_insert(this.ptr, item.Handle, index)); // Addref the item item.AddRef(); }