Ejemplo n.º 1
0
        public void Subscribe(EventCallback callback)
        {
            NativeImports.TIO_DATA start = new NativeImports.TIO_DATA();// = NativeImports.TioDataConverter.FromObject(null);

            NativeImports.tio_container_subscribe(
                _nativeContainerHandle,
                ref start,
                delegate(int result,
                         IntPtr cookie,
                         IntPtr handle,
                         uint eventCode,
                         ref NativeImports.TIO_DATA key,
                         ref NativeImports.TIO_DATA value,
                         ref NativeImports.TIO_DATA metadata)
            {
                EventCode convertedEventCode = (EventCode)eventCode;

                callback(
                    convertedEventCode,
                    NativeImports.TioDataConverter.ToObject(key),
                    NativeImports.TioDataConverter.ToObject(value),
                    NativeImports.TioDataConverter.ToObject(metadata));
            },
                IntPtr.Zero);
        }
Ejemplo n.º 2
0
        public void Disconnect()
        {
            NativeImports.tio_disconnect(_nativeHandle);

            _nativeHandle = new IntPtr();
            _host         = null;
            _port         = 0;
        }
Ejemplo n.º 3
0
        public Connection(string host, short port)
        {
            int result = NativeImports.tio_connect(host, port, out _nativeHandle);

            NativeImports.ThrowOnNativeApiError(result);

            _host = host;
            _port = port;
        }
Ejemplo n.º 4
0
        public Container Open(string name)
        {
            IntPtr handle = new IntPtr();

            int result = NativeImports.tio_open(_nativeHandle, name, "", out handle);

            NativeImports.ThrowOnNativeApiError(result);

            return(new Container(handle, name));
        }
Ejemplo n.º 5
0
 void Free()
 {
     if (_tiodata.data_type == TIO_DATA_TYPE_STRING)
     {
         NativeImports.tiodata_set_as_none(ref _tiodata);
     }
     else
     {
         _tiodata.data_type = TIO_DATA_TYPE_NONE;
     }
 }
Ejemplo n.º 6
0
        public string GetProperty(string key)
        {
            int result;

            using (NativeImports.TioDataConverter
                   k = NativeImports.TioDataConverter.FromObject(key),
                   v = new NativeImports.TioDataConverter())
            {
                result = NativeImports.tio_container_propget(
                    _nativeContainerHandle,
                    ref k._tiodata,
                    out v._tiodata);

                NativeImports.ThrowOnNativeApiError(result);

                return(v.ToString());
            }
        }
Ejemplo n.º 7
0
        public void Set(object key, object value, object metadata = null)
        {
            using (NativeImports.TioDataConverter
                   k = NativeImports.TioDataConverter.FromObject(key),
                   v = NativeImports.TioDataConverter.FromObject(value),
                   m = NativeImports.TioDataConverter.FromObject(metadata))
            {
                int result;

                result = NativeImports.tio_container_set(
                    _nativeContainerHandle,
                    ref k._tiodata,
                    ref v._tiodata,
                    ref m._tiodata);

                NativeImports.ThrowOnNativeApiError(result);
            }
        }
Ejemplo n.º 8
0
        public object Get(object searchKey)
        {
            object ret;

            using (NativeImports.TioDataConverter sk = NativeImports.TioDataConverter.FromObject(searchKey),
                   k = new NativeImports.TioDataConverter(),
                   v = new NativeImports.TioDataConverter(),
                   m = new NativeImports.TioDataConverter())
            {
                int result;

                result = NativeImports.tio_container_get(
                    _nativeContainerHandle,
                    ref sk._tiodata,
                    out k._tiodata,
                    out v._tiodata,
                    out m._tiodata);

                ret = v.AsObject();
            }

            return(ret);
        }
Ejemplo n.º 9
0
 public void Query(QueryCallback callback)
 {
     NativeImports.tio_container_query(
         _nativeContainerHandle,
         0,
         0,
         null,
         delegate(int result,
                  IntPtr handle,
                  IntPtr cookie,
                  uint queryid,
                  string containerName,
                  ref NativeImports.TIO_DATA key,
                  ref NativeImports.TIO_DATA value,
                  ref NativeImports.TIO_DATA metadata)
     {
         callback(
             NativeImports.TioDataConverter.ToObject(key),
             NativeImports.TioDataConverter.ToObject(value),
             NativeImports.TioDataConverter.ToObject(metadata));
     },
         IntPtr.Zero);
 }
Ejemplo n.º 10
0
        public void Ping(string host, short port)
        {
            int result = NativeImports.tio_ping(_nativeHandle, "tioclient");

            NativeImports.ThrowOnNativeApiError(result);
        }
Ejemplo n.º 11
0
 public void Close()
 {
     int result = NativeImports.tio_disconnect(_nativeHandle);
 }
Ejemplo n.º 12
0
 static Connection()
 {
     NativeImports.tio_initialize();
 }