[Calendar]Remove invalid exception
[platform/core/csapi/tizenfx.git] / src / Tizen.Pims.Calendar / Tizen.Pims.Calendar / CalendarList.cs
index fdcf2a9..9c8b7d0 100644 (file)
  */
 
 using System;
-using System.Collections;
-using System.Collections.Generic;
 
 namespace Tizen.Pims.Calendar
 {
     /// <summary>
     /// A list of records with the same type.
     /// </summary>
+    /// <since_tizen> 4 </since_tizen>
     public class CalendarList:IDisposable
     {
         private Int64 _memoryPressure = 20;
@@ -33,18 +32,27 @@ namespace Tizen.Pims.Calendar
         {
             _listHandle = handle;
 
-            _memoryPressure += this.Count * CalendarViews.AverageSizeOfRecord;
+            int error = Interop.List.First(_listHandle);
+            if (CalendarError.None != (CalendarError)error)
+            {
+                Log.Error(Globals.LogTag, "MoveFirst Failed with error " + error);
+                throw CalendarErrorFactory.GetException(error);
+            }
+
+            _memoryPressure += this.Count * CalendarViews.Record.AverageSize;
             GC.AddMemoryPressure(_memoryPressure);
         }
 
         /// <summary>
         /// Creates a calendar list.
         /// </summary>
-        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <since_tizen> 4 </since_tizen>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
         public CalendarList()
         {
-            int error = Interop.Calendar.List.Create(out _listHandle);
+            int error = Interop.List.Create(out _listHandle);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "CalendarList Failed with error " + error);
@@ -53,14 +61,11 @@ namespace Tizen.Pims.Calendar
             GC.AddMemoryPressure(_memoryPressure);
         }
 
-        ~CalendarList()
-        {
-            Dispose(false);
-        }
-
         /// <summary>
         /// The count of the calendar entity.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <value>The count of calendar entity.</value>
         public int Count
         {
             get
@@ -68,7 +73,7 @@ namespace Tizen.Pims.Calendar
                 if (_count == -1)
                 {
                     int count = -1;
-                    int error = Interop.Calendar.List.GetCount(_listHandle, out count);
+                    int error = Interop.List.GetCount(_listHandle, out count);
                     if (CalendarError.None != (CalendarError)error)
                     {
                         Log.Error(Globals.LogTag, "GetCount Failed with error " + error);
@@ -79,20 +84,31 @@ namespace Tizen.Pims.Calendar
             }
         }
 
+        /// <summary>
+        /// Destroy CalendarList resource.
+        /// </summary>
+        ~CalendarList()
+        {
+            Dispose(false);
+        }
+
 #region IDisposable Support
         private bool disposedValue = false; // To detect redundant calls
 
+        /// <summary>
+        /// Disposes of the resources (other than memory) used by the CalendarList.
+        /// </summary>
+        /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
         protected virtual void Dispose(bool disposing)
         {
             if (!disposedValue)
             {
                 Log.Debug(Globals.LogTag, "Dispose :" + disposing);
 
-                int error = Interop.Calendar.List.Destroy(_listHandle, true);
+                int error = Interop.List.Destroy(_listHandle, true);
                 if (CalendarError.None != (CalendarError)error)
                 {
                     Log.Error(Globals.LogTag, "Destroy Failed with error " + error);
-                    throw CalendarErrorFactory.GetException(error);
                 }
                 disposedValue = true;
                 GC.RemoveMemoryPressure(_memoryPressure);
@@ -101,23 +117,25 @@ namespace Tizen.Pims.Calendar
 
         /// <summary>
         /// Releases all resources used by the CalendarList.
-        /// It should be called after finished using of the object.
+        /// It should be called after having finished using of the object.
         /// </summary>
         public void Dispose()
         {
             Dispose(true);
+            GC.SuppressFinalize(this);
         }
 #endregion
 
         /// <summary>
         /// Adds a record to the calendar list.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="record">The record to be added</param>
-        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
-        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         public void AddRecord(CalendarRecord record)
         {
-            int error = Interop.Calendar.List.Add(_listHandle, record._recordHandle);
+            int error = Interop.List.Add(_listHandle, record._recordHandle);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "AddRecord Failed with error " + error);
@@ -125,18 +143,19 @@ namespace Tizen.Pims.Calendar
             }
             record._disposedValue = true;
             _count = -1;
-            _memoryPressure += CalendarViews.AverageSizeOfRecord;
+            _memoryPressure += CalendarViews.Record.AverageSize;
         }
 
         /// <summary>
         /// Removes a record from the calendar list.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="record">The record to be removed</param>
-        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
-        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         public void RemoveRecord(CalendarRecord record)
         {
-            int error = Interop.Calendar.List.Remove(_listHandle, record._recordHandle);
+            int error = Interop.List.Remove(_listHandle, record._recordHandle);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "RemoveRecord Failed with error " + error);
@@ -144,19 +163,22 @@ namespace Tizen.Pims.Calendar
             }
             record._disposedValue = false;
             _count = -1;
-            _memoryPressure -= CalendarViews.AverageSizeOfRecord;
+            _memoryPressure -= CalendarViews.Record.AverageSize;
         }
 
         /// <summary>
         /// Retrieves a record from the calendar list.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <returns>
         /// calendar record
         /// </returns>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         public CalendarRecord GetCurrentRecord()
         {
             IntPtr handle;
-            int error = Interop.Calendar.List.GetCurrentRecordP(_listHandle, out handle);
+            int error = Interop.List.GetCurrentRecordP(_listHandle, out handle);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "GetCurrentRecord Failed with error " + error);
@@ -168,12 +190,15 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Moves a calendar list to the previous position.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <returns>
         /// if cursor is moved to the end, it returns false.
         /// </returns>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         public bool MovePrevious()
         {
-            int error = Interop.Calendar.List.Prev(_listHandle);
+            int error = Interop.List.Prev(_listHandle);
             if (CalendarError.None == (CalendarError)error)
             {
                 return true;
@@ -193,12 +218,15 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Moves a calendar list to the next position.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <returns>
         /// if cursor is moved to the end, it returns false.
         /// </returns>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         public bool MoveNext()
         {
-            int error = Interop.Calendar.List.Next(_listHandle);
+            int error = Interop.List.Next(_listHandle);
             if (CalendarError.None == (CalendarError)error)
             {
                 return true;
@@ -218,9 +246,12 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Moves a calendar list to the first position.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         public void MoveFirst()
         {
-            int error = Interop.Calendar.List.First(_listHandle);
+            int error = Interop.List.First(_listHandle);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "MoveFirst Failed with error " + error);
@@ -231,9 +262,12 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Moves a calendar list to the last position.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         public void MoveLast()
         {
-            int error = Interop.Calendar.List.Last(_listHandle);
+            int error = Interop.List.Last(_listHandle);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "MoveLast Failed with error " + error);