2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Collections.Generic;
19 using static Interop.Calendar.Service;
21 namespace Tizen.Pims.Calendar
24 /// A class for managing calendar information. It allows applications to use calendar service.
26 public class CalendarManager : IDisposable
28 private CalendarDatabase _db = null;
33 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
34 public CalendarManager()
36 int error = Interop.Calendar.Service.Connect();
37 if (CalendarError.None != (CalendarError)error)
39 Log.Error(Globals.LogTag, "Connect Failed with error " + error);
40 throw CalendarErrorFactory.GetException(error);
42 _db = new CalendarDatabase();
50 #region IDisposable Support
51 /// To detect redundant calls
52 private bool disposedValue = false;
54 protected virtual void Dispose(bool disposing)
58 Log.Debug(Globals.LogTag, "Dispose :" + disposing);
60 int error = Interop.Calendar.Service.Disconnect();
61 if (CalendarError.None != (CalendarError)error)
63 Log.Error(Globals.LogTag, "Disconnect Failed with error " + error);
64 throw CalendarErrorFactory.GetException(error);
71 /// Releases all resources used by the CalendarManager.
72 /// It should be called after finished using of the object.
83 public CalendarDatabase Database