示例#1
0
        private static string GetQuery(IntPtr handlePtr, SafeBundleHandle data, string where, OperationType type)
        {
            Interop.DataControl.SafeDataControlHandle handle = new Interop.DataControl.SafeDataControlHandle(handlePtr, false);
            string query = null;

            switch (type)
            {
            case OperationType.Select:
                break;

            case OperationType.Update:
                query = Interop.DataControl.CreateUpdateStatement(handle, data, where);
                break;

            case OperationType.Delete:
                query = Interop.DataControl.CreateDeleteStatement(handle, where);
                break;

            case OperationType.Insert:
                query = Interop.DataControl.CreateInsertStatement(handle, data);
                break;

            default:
                break;
            }
            handle.Dispose();

            return(query);
        }
示例#2
0
        private static Provider GetProvider(IntPtr handlePtr)
        {
            Interop.DataControl.SafeDataControlHandle handle = new Interop.DataControl.SafeDataControlHandle(handlePtr, false);
            Provider provider = null;
            string   dataID;

            Interop.DataControl.DataControlGetDataId(handle, out dataID);
            if (dataID != null && _providerDict.ContainsKey(dataID))
            {
                provider = _providerDict[dataID];
                Log.Info(LogTag, "DataID :" + dataID + ", hash code : " + provider.GetHashCode().ToString());
            }
            handle.Dispose();

            return(provider);
        }
示例#3
0
        /// <summary>
        /// Releases the unmanaged resources used by the Consumer class specifying whether to perform a normal dispose operation.
        /// </summary>
        /// <param name="disposing">true for a normal dispose operation; false to finalize the handle.</param>
        /// <since_tizen> 3 </since_tizen>
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (_changeCallbackID > 0)
                {
                    Interop.DataControl.RemoveDataChangeCallback(_handle, _changeCallbackID);
                }

                CallbackManager.UnregisterCallback(_handle, _providerID);
                _handle.Dispose();
                _disposed = true;
            }

            if (disposing)
            {
                GC.SuppressFinalize(this);
            }
        }
示例#4
0
        private static string CreateSelectQuery(IntPtr handlePtr, string[] columnList, int columnCount, string where, string order, int pageNum, int countPerPage)
        {
            Interop.DataControl.SafeDataControlHandle handle = new Interop.DataControl.SafeDataControlHandle(handlePtr, false);
            string query = "SELECT";
            string dataId;

            if (columnList == null)
            {
                query += " * ";
            }
            else
            {
                for (int i = 0; i < columnCount; i++)
                {
                    if (i != 0)
                    {
                        query += ",";
                    }

                    query += " " + columnList[i];
                }
            }

            Interop.DataControl.DataControlGetDataId(handle, out dataId);
            query += " FROM " + dataId;
            if (where != null)
            {
                query += " WHERE " + where;
            }

            if (order != null)
            {
                query += " ORDER BY " + order;
            }

            if (pageNum != 0)
            {
                query += " LIMIT " + countPerPage + " OFFSET " + (countPerPage * (pageNum - 1));
            }
            handle.Dispose();
            return(query);
        }