예제 #1
0
        /// <summary>
        /// Initializes the Consumer class with the providerId and the ataId.
        /// </summary>
        /// <param name="providerId">The DataControl Provider ID.</param>
        /// <param name="dataId">The DataControl Data ID.</param>
        /// <exception cref="ArgumentException">Thrown in case of an invalid parmaeter.</exception>
        /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
        /// <since_tizen> 3 </since_tizen>
        public Consumer(string providerId, string dataId)
        {
            ResultType ret;

            if (string.IsNullOrEmpty(providerId))
            {
                ErrorFactory.ThrowException(ResultType.InvalidParameter, false, "providerId");
            }

            if (string.IsNullOrEmpty(dataId))
            {
                ErrorFactory.ThrowException(ResultType.InvalidParameter, false, "dataId");
            }

            ret = Interop.DataControl.DataControlCreate(out _handle);
            if (ret != ResultType.Success)
            {
                ErrorFactory.ThrowException(ret, false, "Creating data control handle is failed");
            }

            Interop.DataControl.DataControlSetProviderId(_handle, providerId);
            Interop.DataControl.DataControlSetDataId(_handle, dataId);
            _lock.WaitOne();
            CallbackManager.RegisterCallback(_handle, providerId);
            _lock.ReleaseMutex();
            _dataID     = dataId;
            _providerID = providerId;
        }