示例#1
0
        public IList <string> GetIndexes()
        {
            object retVal = null;

            ThreadSafety.DoLocked(() =>
            {
                CheckOpen();
                var result = new C4SliceResult();
                LiteCoreBridge.Check(err =>
                {
                    result = NativeRaw.c4db_getIndexes(c4db, err);
                    return(result.buf != null);
                });

                var val = NativeRaw.FLValue_FromTrustedData(new FLSlice(result.buf, result.size));
                if (val == null)
                {
                    Native.c4slice_free(result);
                    throw new LiteCoreException(new C4Error(C4ErrorCode.CorruptIndexData));
                }

                retVal = FLValueConverter.ToCouchbaseObject(val, this, true, typeof(string));
                Native.c4slice_free(result);
            });

            return(retVal as IList <string> ?? new List <string>());
        }
示例#2
0
        public unsafe void TestSerializationRoundTrip()
        {
            var masterList = new List <Dictionary <string, object> >();
            var settings   = new JsonSerializerSettings {
                DateParseHandling = DateParseHandling.None
            };
            var s = JsonSerializer.CreateDefault(settings);

            ReadFileByLines("C/tests/data/iTunesMusicLibrary.json", line =>
            {
                using (var reader = new JsonTextReader(new StringReader(line))) {
                    masterList.Add(s.Deserialize <Dictionary <string, object> >(reader));
                }

                return(true);
            });

            var retrieved = default(List <Dictionary <string, object> >);

            Db.InBatch(() =>
            {
                using (var flData = masterList.FLEncode()) {
                    retrieved =
                        FLValueConverter.ToCouchbaseObject(NativeRaw.FLValue_FromData((FLSlice)flData, FLTrust.Trusted), Db,
                                                           true, typeof(Dictionary <,>).MakeGenericType(typeof(string), typeof(object))) as
                        List <Dictionary <string, object> >;
                }
            });



            var i = 0;

            foreach (var entry in retrieved)
            {
                var entry2 = masterList[i];
                foreach (var key in entry.Keys)
                {
                    entry[key].Should().Be(entry2[key]);
                }

                i++;
            }
        }
 public object ToObject(FLValue *value, bool dotNetType)
 {
     return(FLValueConverter.ToCouchbaseObject(value, Db, dotNetType));
 }