Release 4.0.0-preview1-00271
[platform/core/csapi/tizenfx.git] / src / Tizen.Pims.Calendar / Tizen.Pims.Calendar / CalendarFilter.cs
index fd59b0f..e121fcc 100644 (file)
  */
 
 using System;
-using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
 
 namespace Tizen.Pims.Calendar
 {
     /// <summary>
     /// A filter includes the conditions for the search.
     /// </summary>
+    /// <since_tizen> 4 </since_tizen>
     public class CalendarFilter:IDisposable
     {
         internal IntPtr _filterHandle;
@@ -29,26 +30,30 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Creates a filter with a condition for a string type.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <feature>http://tizen.org/privilege/calendar</feature>
         /// <param name="viewUri">The view URI of a filter</param>
         /// <param name="propertyId">The property ID to add a condition</param>
         /// <param name="matchType">The match flag</param>
         /// <param name="matchValue">The match value</param>
-        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")]
         public CalendarFilter(string viewUri, uint propertyId, StringMatchType matchType, string matchValue)
         {
             int error = 0;
-            error = Interop.Calendar.Filter.Create(viewUri, out _filterHandle);
+            error = Interop.Filter.Create(viewUri, out _filterHandle);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
                 throw CalendarErrorFactory.GetException(error);
             }
 
-            error = Interop.Calendar.Filter.AddString(_filterHandle, propertyId, matchType, matchValue);
+            error = Interop.Filter.AddString(_filterHandle, propertyId, matchType, matchValue);
             if (CalendarError.None != (CalendarError)error)
             {
+                Interop.Filter.Destroy(_filterHandle);
                 Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
                 throw CalendarErrorFactory.GetException(error);
             }
@@ -57,26 +62,30 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Creates a filter with a condition for an integer type.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <feature>http://tizen.org/privilege/calendar</feature>
         /// <param name="viewUri">The view URI of a filter</param>
         /// <param name="propertyId">The property ID to add a condition</param>
         /// <param name="matchType">The match flag</param>
         /// <param name="matchValue">The match value</param>
-        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")]
         public CalendarFilter(string viewUri, uint propertyId, IntegerMatchType matchType, int matchValue)
         {
             int error = 0;
-            error = Interop.Calendar.Filter.Create(viewUri, out _filterHandle);
+            error = Interop.Filter.Create(viewUri, out _filterHandle);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
                 throw CalendarErrorFactory.GetException(error);
             }
 
-            error = Interop.Calendar.Filter.AddInteger(_filterHandle, propertyId, matchType, matchValue);
+            error = Interop.Filter.AddInteger(_filterHandle, propertyId, matchType, matchValue);
             if (CalendarError.None != (CalendarError)error)
             {
+                Interop.Filter.Destroy(_filterHandle);
                 Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
                 throw CalendarErrorFactory.GetException(error);
             }
@@ -85,26 +94,30 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Creates a filter with a condition for long type.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <feature>http://tizen.org/privilege/calendar</feature>
         /// <param name="viewUri">The view URI of a filter</param>
         /// <param name="propertyId">The property ID to add a condition</param>
         /// <param name="matchType">The match flag</param>
         /// <param name="matchValue">The match value</param>
-        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")]
         public CalendarFilter(string viewUri, uint propertyId, IntegerMatchType matchType, long matchValue)
         {
             int error = 0;
-            error = Interop.Calendar.Filter.Create(viewUri, out _filterHandle);
+            error = Interop.Filter.Create(viewUri, out _filterHandle);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
                 throw CalendarErrorFactory.GetException(error);
             }
 
-            error = Interop.Calendar.Filter.AddLong(_filterHandle, propertyId, matchType, matchValue);
+            error = Interop.Filter.AddLong(_filterHandle, propertyId, matchType, matchValue);
             if (CalendarError.None != (CalendarError)error)
             {
+                Interop.Filter.Destroy(_filterHandle);
                 Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
                 throw CalendarErrorFactory.GetException(error);
             }
@@ -113,26 +126,30 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Creates a filter with a condition for double type.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <feature>http://tizen.org/privilege/calendar</feature>
         /// <param name="viewUri">The view URI of a filter</param>
         /// <param name="propertyId">The property ID to add a condition</param>
         /// <param name="matchType">The match flag</param>
         /// <param name="matchValue">The match value</param>
-        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")]
         public CalendarFilter(string viewUri, uint propertyId, IntegerMatchType matchType, double matchValue)
         {
             int error = 0;
-            error = Interop.Calendar.Filter.Create(viewUri, out _filterHandle);
+            error = Interop.Filter.Create(viewUri, out _filterHandle);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
                 throw CalendarErrorFactory.GetException(error);
             }
 
-            error = Interop.Calendar.Filter.AddDouble(_filterHandle, propertyId, matchType, matchValue);
+            error = Interop.Filter.AddDouble(_filterHandle, propertyId, matchType, matchValue);
             if (CalendarError.None != (CalendarError)error)
             {
+                Interop.Filter.Destroy(_filterHandle);
                 Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
                 throw CalendarErrorFactory.GetException(error);
             }
@@ -141,32 +158,39 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Creates a filter with a condition for CalendarTime type.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <feature>http://tizen.org/privilege/calendar</feature>
         /// <param name="viewUri">The view URI of a filter</param>
         /// <param name="propertyId">The property ID to add a condition</param>
         /// <param name="matchType">The match flag</param>
         /// <param name="matchValue">The match value</param>
-        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")]
         public CalendarFilter(string viewUri, uint propertyId, IntegerMatchType matchType, CalendarTime matchValue)
         {
             int error = 0;
-            error = Interop.Calendar.Filter.Create(viewUri, out _filterHandle);
+            error = Interop.Filter.Create(viewUri, out _filterHandle);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
                 throw CalendarErrorFactory.GetException(error);
             }
 
-            Interop.Calendar.Record.DateTime time = CalendarRecord.ConvertCalendarTimeToStruct(matchValue);
-            error = Interop.Calendar.Filter.AddCalendarTime(_filterHandle, propertyId, matchType, time);
+            Interop.Record.DateTime time = CalendarRecord.ConvertCalendarTimeToStruct(matchValue);
+            error = Interop.Filter.AddCalendarTime(_filterHandle, propertyId, matchType, time);
             if (CalendarError.None != (CalendarError)error)
             {
+                Interop.Filter.Destroy(_filterHandle);
                 Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
                 throw CalendarErrorFactory.GetException(error);
             }
         }
 
+        /// <summary>
+        /// Destroy filter.
+        /// </summary>
         ~CalendarFilter()
         {
             Dispose(false);
@@ -184,7 +208,7 @@ namespace Tizen.Pims.Calendar
             /// <summary>
             /// Full string, case-insensitive
             /// </summary>
-            Fullstring,
+            FullString,
             /// <summary>
             /// Sub string, case-insensitive
             /// </summary>
@@ -192,11 +216,11 @@ namespace Tizen.Pims.Calendar
             /// <summary>
             /// Start with, case-insensitive
             /// </summary>
-            Startswith,
+            StartsWith,
             /// <summary>
             /// End with, case-insensitive
             /// </summary>
-            Endswith,
+            EndsWith,
             /// <summary>
             /// IS NOT NUL
             /// </summary>
@@ -256,17 +280,20 @@ namespace Tizen.Pims.Calendar
 #region IDisposable Support
         private bool disposedValue = false; // To detect redundant calls
 
+        /// <summary>
+        /// Dispose
+        /// </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.Filter.Destroy(_filterHandle);
+                int error = Interop.Filter.Destroy(_filterHandle);
                 if (CalendarError.None != (CalendarError)error)
                 {
                     Log.Error(Globals.LogTag, "Destroy Failed with error " + error);
-                    throw CalendarErrorFactory.GetException(error);
                 }
                 disposedValue = true;
             }
@@ -274,33 +301,36 @@ namespace Tizen.Pims.Calendar
 
         /// <summary>
         /// Releases all resources used by the CalendarFilter.
-        /// 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 condition for the string type.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <feature>http://tizen.org/privilege/calendar</feature>
         /// <param name="logicalOperator">The operator type</param>
         /// <param name="propertyId">The property ID to add a condition</param>
         /// <param name="matchType">The match flag</param>
-        /// <param name="matchValue">The match valu</param>
-        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
         public void AddCondition(LogicalOperator logicalOperator, uint propertyId, StringMatchType matchType, string matchValue)
         {
-            int error = Interop.Calendar.Filter.AddOperator(_filterHandle, logicalOperator);
+            int error = Interop.Filter.AddOperator(_filterHandle, logicalOperator);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
                 throw CalendarErrorFactory.GetException(error);
             }
 
-            error = Interop.Calendar.Filter.AddString(_filterHandle, propertyId, matchType, matchValue);
+            error = Interop.Filter.AddString(_filterHandle, propertyId, matchType, matchValue);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
@@ -311,22 +341,24 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Adds a condition for the integer type.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <feature>http://tizen.org/privilege/calendar</feature>
         /// <param name="logicalOperator">The operator type</param>
         /// <param name="propertyId">The property ID to add a condition</param>
         /// <param name="matchType">The match flag</param>
-        /// <param name="matchValue">The match valu</param>
-        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
         public void AddCondition(LogicalOperator logicalOperator, uint propertyId, IntegerMatchType matchType, int matchValue)
         {
-            int error = Interop.Calendar.Filter.AddOperator(_filterHandle, logicalOperator);
+            int error = Interop.Filter.AddOperator(_filterHandle, logicalOperator);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
                 throw CalendarErrorFactory.GetException(error);
             }
 
-            error = Interop.Calendar.Filter.AddInteger(_filterHandle, propertyId, matchType, matchValue);
+            error = Interop.Filter.AddInteger(_filterHandle, propertyId, matchType, matchValue);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
@@ -337,22 +369,24 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Adds a condition for the long type.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <feature>http://tizen.org/privilege/calendar</feature>
         /// <param name="logicalOperator">The operator type</param>
         /// <param name="propertyId">The property ID to add a condition</param>
         /// <param name="matchType">The match flag</param>
-        /// <param name="matchValue">The match valu</param>
-        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
         public void AddCondition(LogicalOperator logicalOperator, uint propertyId, IntegerMatchType matchType, long matchValue)
         {
-            int error = Interop.Calendar.Filter.AddOperator(_filterHandle, logicalOperator);
+            int error = Interop.Filter.AddOperator(_filterHandle, logicalOperator);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
                 throw CalendarErrorFactory.GetException(error);
             }
 
-            error = Interop.Calendar.Filter.AddLong(_filterHandle, propertyId, matchType, matchValue);
+            error = Interop.Filter.AddLong(_filterHandle, propertyId, matchType, matchValue);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
@@ -363,22 +397,24 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Adds a condition for the double type.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <feature>http://tizen.org/privilege/calendar</feature>
         /// <param name="logicalOperator">The operator type</param>
         /// <param name="propertyId">The property ID to add a condition</param>
         /// <param name="matchType">The match flag</param>
-        /// <param name="matchValue">The match valu</param>
-        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
         public void AddCondition(LogicalOperator logicalOperator, uint propertyId, IntegerMatchType matchType, double matchValue)
         {
-            int error = Interop.Calendar.Filter.AddOperator(_filterHandle, logicalOperator);
+            int error = Interop.Filter.AddOperator(_filterHandle, logicalOperator);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
                 throw CalendarErrorFactory.GetException(error);
             }
 
-            error = Interop.Calendar.Filter.AddDouble(_filterHandle, propertyId, matchType, matchValue);
+            error = Interop.Filter.AddDouble(_filterHandle, propertyId, matchType, matchValue);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
@@ -389,23 +425,25 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Adds a condition for the CalendarTime type.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <feature>http://tizen.org/privilege/calendar</feature>
         /// <param name="logicalOperator">The operator type</param>
         /// <param name="propertyId">The property ID to add a condition</param>
         /// <param name="matchType">The match flag</param>
-        /// <param name="matchValue">The match valu</param>
-        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <param name="matchValue">The match value</param>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
         public void AddCondition(LogicalOperator logicalOperator, uint propertyId, IntegerMatchType matchType, CalendarTime matchValue)
         {
-            int error = Interop.Calendar.Filter.AddOperator(_filterHandle, logicalOperator);
+            int error = Interop.Filter.AddOperator(_filterHandle, logicalOperator);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
                 throw CalendarErrorFactory.GetException(error);
             }
 
-            Interop.Calendar.Record.DateTime time = CalendarRecord.ConvertCalendarTimeToStruct(matchValue);
-            error = Interop.Calendar.Filter.AddCalendarTime(_filterHandle, propertyId, matchType, time);
+            Interop.Record.DateTime time = CalendarRecord.ConvertCalendarTimeToStruct(matchValue);
+            error = Interop.Filter.AddCalendarTime(_filterHandle, propertyId, matchType, time);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
@@ -416,20 +454,22 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Adds a child filter to a parent filter.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <feature>http://tizen.org/privilege/calendar</feature>
         /// <param name="logicalOperator">The operator type</param>
         /// <param name="filter">The child filter</param>
-        /// <exception cref="NotSupportedException">Thrown when an invoked method is not supported</exception>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
         public void AddFilter(LogicalOperator logicalOperator, CalendarFilter filter)
         {
-            int error = Interop.Calendar.Filter.AddOperator(_filterHandle, logicalOperator);
+            int error = Interop.Filter.AddOperator(_filterHandle, logicalOperator);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
                 throw CalendarErrorFactory.GetException(error);
             }
 
-            error = Interop.Calendar.Filter.AddFilter(_filterHandle, filter._filterHandle);
+            error = Interop.Filter.AddFilter(_filterHandle, filter._filterHandle);
             if (CalendarError.None != (CalendarError)error)
             {
                 Log.Error(Globals.LogTag, "AddFilter Failed with error " + error);