From: Jongkyu Koo Date: Tue, 5 Sep 2017 09:36:06 +0000 (+0900) Subject: replace delegate with EventHandler X-Git-Tag: preview1-00153^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e6476e4aff83a1fbb037ed7f75221ea009d038fa;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git replace delegate with EventHandler Change-Id: I738d921c7ef4a3241402cc140b8b8bdc5362be71 Signed-off-by: Jongkyu Koo --- diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsDatabase.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsDatabase.cs index c868c5625..c1a40432a 100644 --- a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsDatabase.cs +++ b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsDatabase.cs @@ -21,15 +21,6 @@ using System.Runtime.InteropServices; namespace Tizen.Pims.Contacts { - /// - /// Delegate for detecting the contacts database changes - /// - /// The contacts view URI - /// - /// The delegate must be registered using AddDBChangedDelegate. - /// It's invoked when the designated view changes. - /// - public delegate void ContactsDBChanged(string uri); /// /// ContactsDatabase provides methods to manage contacts information from/to the database. @@ -42,7 +33,7 @@ namespace Tizen.Pims.Contacts private Object thisLock = new Object(); private Interop.Database.ContactsDBStatusChangedCallback _contactsDBStatusChangedCallback; private EventHandler _dbStatusChanged; - private Dictionary _delegateMap = new Dictionary(); + private Dictionary> _delegateMap = new Dictionary>(); private Dictionary _callbackMap = new Dictionary(); private Interop.Database.ContactsDBChangedCallback _dbChangedDelegate; @@ -721,15 +712,16 @@ namespace Tizen.Pims.Contacts /// Registers a callback function to be invoked when a record changes. /// /// The view URI of records whose changes are monitored - /// The callback function to register + /// The EventHandler to register [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")] - public void AddDBChangedDelegate(string viewUri, ContactsDBChanged callback) + public void AddDBChangedDelegate(string viewUri, EventHandler DBChanged) { if (_callbackMap[viewUri] == null) { _callbackMap[viewUri] = (string uri, IntPtr userData) => { - _delegateMap[uri](uri); + DBChangedEventArgs args = new DBChangedEventArgs(uri); + _delegateMap[uri]?.Invoke(this, args); }; int error = Interop.Database.AddChangedCb(viewUri, _callbackMap[viewUri], IntPtr.Zero); @@ -740,18 +732,18 @@ namespace Tizen.Pims.Contacts } } - _delegateMap[viewUri] += callback; + _delegateMap[viewUri] += DBChanged; } /// /// Deregisters a callback function. /// /// The view URI of records whose changes are monitored - /// The callback function to register + /// The EventHandler to deregister [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")] - public void RemoveDBChangedDelegate(string viewUri, ContactsDBChanged callback) + public void RemoveDBChangedDelegate(string viewUri, EventHandler DBChanged) { - _delegateMap[viewUri] -= callback; + _delegateMap[viewUri] -= DBChanged; if (_delegateMap[viewUri] == null) { diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsVcard.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsVcard.cs index 3273a9dee..8a7b7c03c 100644 --- a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsVcard.cs +++ b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/ContactsVcard.cs @@ -24,7 +24,7 @@ namespace Tizen.Pims.Contacts /// Delegate for getting a record parsed from a vCard file /// /// The contacts record - /// + /// true to continue with the next iteration of the loop, otherwise false to break out of the loop public delegate bool ParseCallback(ContactsRecord record); /// diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/DBChangedEventArgs.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/DBChangedEventArgs.cs new file mode 100644 index 000000000..591c4a029 --- /dev/null +++ b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/DBChangedEventArgs.cs @@ -0,0 +1,40 @@ +/* +* 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; + +namespace Tizen.Pims.Contacts +{ + /// + /// Event arguments passed when contacts database is changed + /// + public class DBChangedEventArgs : EventArgs + { + internal DBChangedEventArgs(string viewUri) + { + ViewUri = viewUri; + } + + /// + /// The contacts view URI changed. + /// + public string ViewUri + { + get; + internal set; + } + } +} diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/DBStatusChangedEventArgs.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/DBStatusChangedEventArgs.cs index 0257c18d5..ca1a79b0b 100644 --- a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/DBStatusChangedEventArgs.cs +++ b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/DBStatusChangedEventArgs.cs @@ -26,7 +26,7 @@ namespace Tizen.Pims.Contacts { internal DBStatusChangedEventArgs(DBStatus status) { - this.Status = status; + Status = status; } /// diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/NameDisplayOrderChangedEventArgs.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/NameDisplayOrderChangedEventArgs.cs index 8e5dc3d74..228318c4a 100644 --- a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/NameDisplayOrderChangedEventArgs.cs +++ b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/NameDisplayOrderChangedEventArgs.cs @@ -25,7 +25,7 @@ namespace Tizen.Pims.Contacts { internal NameDisplayOrderChangedEventArgs(ContactDisplayOrder displayOrder) { - this.NameDisplayOrder = displayOrder; + NameDisplayOrder = displayOrder; } /// diff --git a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/NameSortingOrderChangedEventArgs.cs b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/NameSortingOrderChangedEventArgs.cs index e3652048c..152ef0b8e 100644 --- a/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/NameSortingOrderChangedEventArgs.cs +++ b/src/Tizen.Pims.Contacts/Tizen.Pims.Contacts/NameSortingOrderChangedEventArgs.cs @@ -25,7 +25,7 @@ namespace Tizen.Pims.Contacts { internal NameSortingOrderChangedEventArgs(ContactSortingOrder SortingOrder) { - this.NameSortingOrder = SortingOrder; + NameSortingOrder = SortingOrder; } ///