CmisSync.Lib.Storage.Database.FileTransmissionStorage.SaveObject C# (CSharp) Method

SaveObject() public method

public SaveObject ( IFileTransmissionObject obj ) : void
obj IFileTransmissionObject
return void
        public void SaveObject(IFileTransmissionObject obj) {
            if (obj == null) {
                throw new ArgumentNullException("obj");
            }

            if (obj.LocalPath == null) {
                throw new ArgumentNullException("obj.LocalPath");
            }

            if (string.IsNullOrEmpty(obj.LocalPath)) {
                throw new ArgumentException("empty string", "obj.LocalPath");
            }

            if (obj.RemoteObjectId == null) {
                throw new ArgumentNullException("obj.RemoteObjectId");
            }

            if (string.IsNullOrEmpty(obj.RemoteObjectId)) {
                throw new ArgumentException("empty string", "obj.RemoteObjectId");
            }

            if (!(obj is FileTransmissionObject)) {
                throw new ArgumentException("require FileTransmissionObject type", "obj");
            }

            using (var tran = this.engine.GetTransaction()) {
                tran.Insert<string, DbCustomSerializer<FileTransmissionObject>>(FileTransmissionObjectsTable, obj.RemoteObjectId, obj as FileTransmissionObject);
                tran.Commit();
            }
        }

Usage Example

 public void GetObjectByLocalPath() {
     var storage = new FileTransmissionStorage(this.engine);
     this.remoteFile.Setup(m => m.Id).Returns("RemoteObjectId");
     var obj = new FileTransmissionObject(TransmissionType.UPLOAD_NEW_FILE, this.localFile.Object, this.remoteFile.Object);
     Assert.DoesNotThrow(() => storage.SaveObject(obj));
     Assert.That(storage.GetObjectByLocalPath(this.localFile.Object.FullName).RemoteObjectId, Is.EqualTo("RemoteObjectId"));
     Assert.That(storage.GetObjectByLocalPath(this.localFile.Object.FullName + ".temp"), Is.Null);
 }
All Usage Examples Of CmisSync.Lib.Storage.Database.FileTransmissionStorage::SaveObject