コード例 #1
0
        public Document Save(MutableDocument document)
        {
            CBDebug.MustNotBeNull(Log.To.Database, Tag, nameof(document), document);

            return(ThreadSafety.DoLocked(() =>
            {
                CheckOpen();
                return Save(document, false);
            }));
        }
コード例 #2
0
        private MutableDocument([NotNull] MutableDocument other)
            : this((Document)other)
        {
            var dict = new MutableDictionaryObject();

            if (other._dict != null)
            {
                foreach (var item in other._dict)
                {
                    dict.SetValue(item.Key, MutableCopy(item.Value));
                }
            }

            _dict = dict;
        }
コード例 #3
0
        public void Save(Couchbase.Lite.Linq.IDocumentModel model)
        {
            CBDebug.MustNotBeNull(Log.To.Database, Tag, nameof(model), model);

            ThreadSafety.DoLocked(() =>
            {
                CheckOpen();
                MutableDocument md = (model.Document as MutableDocument) ?? model.Document?.ToMutable() ?? new MutableDocument();
                md.SetFromModel(model);

                try {
                    var retVal     = Save(md, false);
                    model.Document = retVal;
                } finally {
                    md.Dispose();
                }
            });
        }
コード例 #4
0
        public static MutableDocument ToMutableDocument <T>(this T obj, string id = null)
        {
            MutableDocument document;

            if (id != null)
            {
                document = new MutableDocument(id);
            }
            else
            {
                document = new MutableDocument();
            }

            var dictionary = GetDictionary(obj);

            if (dictionary != null)
            {
                document.SetData(dictionary);
            }

            return(document);
        }