示例#1
0
        internal unsafe void AsInternalObject(Action <C4DocPutRequest_Internal> logic)
        {
            if (logic == null)
            {
                return;
            }

            var internalObject = new C4DocPutRequest_Internal();

            internalObject.deletion         = Convert.ToByte(deletion);
            internalObject.hasAttachments   = Convert.ToByte(hasAttachments);
            internalObject.existingRevision = Convert.ToByte(existingRevision);
            internalObject.allowConflict    = Convert.ToByte(allowConflict);
            var length = history == null ? 0 : history.LongLength;

            internalObject.historyCount = (UIntPtr)length;
            internalObject.save         = Convert.ToByte(save);
            using (var body_ = new C4String(body))
                using (var docID_ = new C4String(docID)) {
                    internalObject.body  = body_.AsC4Slice();
                    internalObject.docID = docID_.AsC4Slice();
                    var c4StringArray = new C4String[length];
                    var nativeArray   = new C4Slice[length];
                    for (int i = 0; i < length; i++)
                    {
                        c4StringArray[i] = new C4String(history[i]);
                        nativeArray[i]   = c4StringArray[i].AsC4Slice();
                    }

                    fixed(C4Slice *history_ = nativeArray)
                    {
                        internalObject.history = history_;
                        try {
                            logic(internalObject);
                        } finally {
                            foreach (var c4str in c4StringArray)
                            {
                                c4str.Dispose();
                            }
                        }
                    }
                }
        }
示例#2
0
        private bool Equals(string other)
        {
            var c4str = new C4String(other);

            return(Equals(c4str.AsC4Slice()));
        }