/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
namespace Tizen.Maps
{
///
/// List of objects to be used in APIs.
///
internal class PlaceAddressList : IDisposable
{
internal Interop.AddressListHandle handle;
private List _list;
///
/// Constructs a map address list object.
///
/// Thrown when the required feature is not supported.
/// Thrown when native operation failed to allocate memory.
public PlaceAddressList()
{
handle = new Interop.AddressListHandle();
}
internal PlaceAddressList(Interop.AddressListHandle nativeHandle)
{
handle = nativeHandle;
}
///
/// Destroy the PlaceAddressList object.
///
~PlaceAddressList()
{
Dispose(false);
}
///
/// Gets an iterator for addresses in this list.
///
public IEnumerable Addresses
{
get
{
if (_list == null)
{
_list = new List();
handle.Foreach(addressHandle => _list.Add(new PlaceAddress(addressHandle)));
}
return _list;
}
}
#region IDisposable Support
private bool _disposedValue = false;
///
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
///
/// If true, managed and unmanaged resources can be disposed, otherwise only unmanaged resources can be disposed.
protected virtual void Dispose(bool disposing)
{
if (!_disposedValue)
{
if (disposing)
{
_list?.Clear();
}
handle?.Dispose();
_disposedValue = true;
}
}
///
/// Releases all the resources used by this object.
///
/// 3
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
}
}