[Calendar]Remove invalid exception
[platform/core/csapi/tizenfx.git] / src / Tizen.Pims.Calendar / Tizen.Pims.Calendar / CalendarDatabase.cs
index 0b75c81..c088bd5 100644 (file)
@@ -19,48 +19,31 @@ using System.Collections.Generic;
 using System.Runtime.InteropServices;
 using System.Diagnostics.CodeAnalysis;
 
-/// <summary>
-/// The Calendar Service API provides functions, enumerations used in the entire Content Service.
-/// </summary>
-/// <remarks>
-/// The Calendar Service API provides functions and ienumerations used in the entire Content Service.
-/// The Information about calendar items i.e. book, event, todo, alarm, attendee and extended are managed in the database
-/// and operations that involve database requires an active connection with the calendar service.
-/// </remarks>
-
 namespace Tizen.Pims.Calendar
 {
     /// <summary>
     /// CalendarDatabase provides methods to manage calendar information from/to the database.
     /// </summary>
     /// <remarks>
-    /// This class allows user to access/create/update db operations for calendar information.
+    /// This class allows user to access/create/update/delete db operations for calendar information.
+    /// CalendarDatabase is created by CalendarManager.
     /// </remarks>
+    /// <since_tizen> 4 </since_tizen>
     public class CalendarDatabase
     {
-        /// <summary>
-        /// Delegete for detecting the calendar database changes.
-        /// </summary>
-        /// <param name="uri">The record uri</param>
-        /// <remarks>
-        /// The delegate must be registered using AddDBChangedDelegate.
-        /// It's invoked when the designated view changes.
-        /// </remarks>
-        public delegate void CalendarDBChanged(string uri);
-
         private Object thisLock = new Object();
-        private Dictionary<string, CalendarDBChanged> _callbackMap = new Dictionary<string, CalendarDBChanged>();
-        private Dictionary<string, Interop.Database.DBChangedCallback> _delegateMap = new Dictionary<string, Interop.Database.DBChangedCallback>();
-        private Interop.Database.DBChangedCallback _dbChangedDelegate;
+        private Dictionary<string, EventHandler<DBChangedEventArgs>> _eventHandlerMap = new Dictionary<string, EventHandler<DBChangedEventArgs>>();
+        private Dictionary<string, Interop.Database.DBChangedCallback> _callbackMap = new Dictionary<string, Interop.Database.DBChangedCallback>();
 
         internal CalendarDatabase()
         {
-            ///To be created in CalendarManager only
+            /*To be created in CalendarManager only*/
         }
 
         /// <summary>
         /// The calendar database version.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <value>The current calendar database version.</value>
         [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
         public int Version
@@ -80,6 +63,7 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Gets last successful changed calendar database version on the current connection.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <returns>The last successful changed calendar database version on the current connection</returns>
         /// <privilege>http://tizen.org/privilege/calendar.read</privilege>
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
@@ -104,11 +88,13 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Inserts a record into the calendar database.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="record">The record to be inserted</param>
         /// <returns>The ID of inserted record</returns>
         /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
-        /// <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>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
@@ -128,14 +114,16 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Gets a record from the calendar database.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="viewUri">The view URI of a record</param>
         /// <param name="recordId">The record ID</param>
         /// <returns>
         /// The record associated with the record ID
         /// </returns>
         /// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
-        /// <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>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
@@ -161,10 +149,12 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Updates a record in the calendar database.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="record">The record to be updated</param>
         /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
-        /// <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>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
@@ -182,11 +172,13 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Deletes a record from the calendar database with related child records.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="viewUri">The view URI of a record</param>
         /// <param name="recordId">The record ID to be deleted</param>
         /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
-        /// <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>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
@@ -205,11 +197,13 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Replaces a record in the calendar database.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="record">The record to be replaced</param>
         /// <param name="id">the record id</param>
         /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
-        /// <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>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
@@ -227,6 +221,7 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Retrieves all records as a list.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="viewUri">The view URI to get records from</param>
         /// <param name="offset">The index from which results are received</param>
         /// <param name="limit">The maximum number of results(value 0 is used for all records)</param>
@@ -234,8 +229,9 @@ namespace Tizen.Pims.Calendar
         /// The record list
         /// </returns>
         /// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
-        /// <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>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
@@ -256,6 +252,7 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Retrieves records using a query.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="query">The query used to filter results</param>
         /// <param name="offset">The index from which results are received</param>
         /// <param name="limit">The maximum number of results(value 0 is used for all records)</param>
@@ -263,9 +260,9 @@ namespace Tizen.Pims.Calendar
         /// CalendarList
         /// </returns>
         /// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
-        /// <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>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
         [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
@@ -284,13 +281,15 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Inserts multiple records into the calendar database as a batch operation.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="list">The record list</param>
         /// <returns>
         /// The inserted record id array
         /// </returns>
         /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
-        /// <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>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
@@ -314,10 +313,12 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Updates multiple records into the calendar database as a batch operation.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="list">The record list</param>
         /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
-        /// <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>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
@@ -335,11 +336,13 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Deletes multiple records with related child records from the calendar database as a batch operation.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="viewUri">The view URI of the records to delete</param>
         /// <param name="idArray">The record IDs to delete</param>
         /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
-        /// <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>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
@@ -358,11 +361,12 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Deletes multiple records with related child records from the calendar database as a batch operation.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="list">The record list</param>
         /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
-        /// <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>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
         public void Delete(CalendarList list)
@@ -405,11 +409,13 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Replaces multiple records in the calendar database as a batch operation.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="list">The record list</param>
         /// <param name="idArray">The record IDs</param>
         /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
-        /// <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>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
@@ -427,16 +433,18 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Retrieves records with the given calendar database version.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="viewUri">The view URI to get records from</param>
         /// <param name="BookId">The calendar book ID to filter</param>
         /// <param name="calendarDBVersion">The calendar database version</param>
-        /// <param name="currentDBVersion"The current calendar database versio></param>
+        /// <param name="currentDBVersion">The current calendar database version</param>
         /// <returns>
         /// The record list
         /// </returns>
         /// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
-        /// <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>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
@@ -457,6 +465,7 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Gets the record count of a specific view.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="viewUri">The view URI to get records from</param>
         /// <returns>
         /// The count of records
@@ -479,6 +488,7 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Gets the record count with a query.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="query">The query used for filtering the results</param>
         /// <returns>
         /// The count of records
@@ -499,58 +509,90 @@ namespace Tizen.Pims.Calendar
 
         /// <summary>
         /// Registers a callback function to be invoked when a record changes.
+        /// <since_tizen> 4 </since_tizen>
         /// </summary>
         /// <param name="viewUri">The view URI of the record to subscribe for change notifications</param>
-        /// <param name="callback">The callback function to register</param>
+        /// <param name="DBChanged">The EventHandler to register</param>
         /// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</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>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
         [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")]
-        public void AddDBChangedDelegate(string viewUri, CalendarDBChanged callback)
+        public void AddDBChangedDelegate(string viewUri, EventHandler<DBChangedEventArgs> DBChanged)
         {
             Log.Debug(Globals.LogTag, "AddDBChangedDelegate");
 
-            _dbChangedDelegate = (string uri, IntPtr userData) =>
-            {
-                _callbackMap[uri](uri);
-            };
-            int error = Interop.Database.AddChangedCallback(viewUri, _dbChangedDelegate, IntPtr.Zero);
-            if (CalendarError.None != (CalendarError)error)
-            {
-                Log.Error(Globals.LogTag, "AddDBChangedDelegate Failed with error " + error);
-                throw CalendarErrorFactory.GetException(error);
-            }
-            _callbackMap[viewUri] = callback;
-            _delegateMap[viewUri] = _dbChangedDelegate;
+                       if (!_callbackMap.ContainsKey(viewUri))
+                       {
+                               _callbackMap[viewUri] = (string uri, IntPtr userData) =>
+                               {
+                                       DBChangedEventArgs args = new DBChangedEventArgs(uri);
+                                       _eventHandlerMap[uri]?.Invoke(this, args);
+                               };
+
+                               int error = Interop.Database.AddChangedCallback(viewUri, _callbackMap[viewUri], IntPtr.Zero);
+                               if (CalendarError.None != (CalendarError)error)
+                               {
+                                       Log.Error(Globals.LogTag, "AddDBChangedDelegate Failed with error " + error);
+                                       throw CalendarErrorFactory.GetException(error);
+                               }
+                       }
+
+                       EventHandler<DBChangedEventArgs> handler = null;
+                       if (!_eventHandlerMap.TryGetValue(viewUri, out handler))
+                               _eventHandlerMap.Add(viewUri, null);
+
+                       _eventHandlerMap[viewUri] = handler + DBChanged;
         }
 
         /// <summary>
         /// Deregisters a callback function.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="viewUri">The view URI of the record to subscribe for change notifications</param>
-        /// <param name="callback">The callback function to register</param>
+        /// <param name="DBChanged">The EventHandler to deregister</param>
         /// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
         [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")]
-        public void RemoveDBChangedDelegate(string viewUri, CalendarDBChanged callback)
+        public void RemoveDBChangedDelegate(string viewUri, EventHandler<DBChangedEventArgs> DBChanged)
         {
             Log.Debug(Globals.LogTag, "RemoveDBChangedDelegate");
 
-            int error = Interop.Database.RemoveChangedCallback(viewUri, _delegateMap[viewUri], IntPtr.Zero);
-            if (CalendarError.None != (CalendarError)error)
+            EventHandler<DBChangedEventArgs> handler = null;
+            if (!_eventHandlerMap.TryGetValue(viewUri, out handler))
+                _eventHandlerMap.Add(viewUri, null);
+            else
+                _eventHandlerMap[viewUri] = handler - DBChanged;
+
+            if (_eventHandlerMap[viewUri] == null)
             {
-                Log.Error(Globals.LogTag, "RemoveDBChangedDelegate Failed with error " + error);
-                throw CalendarErrorFactory.GetException(error);
-            }
-            _callbackMap.Remove(viewUri);
-            _delegateMap.Remove(viewUri);
+                               int error = Interop.Database.RemoveChangedCallback(viewUri, _callbackMap[viewUri], IntPtr.Zero);
+                               if (CalendarError.None != (CalendarError)error)
+                               {
+                                       Log.Error(Globals.LogTag, "RemoveDBChangedDelegate Failed with error " + error);
+                                       throw CalendarErrorFactory.GetException(error);
+                               }
+                               _callbackMap.Remove(viewUri);
+                       }
         }
 
         /// <summary>
         /// Link a record to another record.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="baseId">The base record ID</param>
         /// <param name="recordId">The record ID to link to</param>
         /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
-        /// <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>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
@@ -569,10 +611,12 @@ namespace Tizen.Pims.Calendar
         /// <summary>
         /// Unlink a record from base record.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         /// <param name="recordId">The record ID to unlink</param>
         /// <privilege>http://tizen.org/privilege/calendar.write</privilege>
+        /// <feature>http://tizen.org/feature/calendar</feature>
+        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
-        /// <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>
         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
         /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>