CmisSync.Lib.Storage.Database.FileTransmissionStorage.GetObjectByLocalPath C# (CSharp) Метод

GetObjectByLocalPath() публичный Метод

public GetObjectByLocalPath ( string localPath ) : IFileTransmissionObject
localPath string
Результат IFileTransmissionObject
        public IFileTransmissionObject GetObjectByLocalPath(string localPath) {
            using (var tran = this.engine.GetTransaction()) {
                foreach (var row in tran.SelectForward<string, DbCustomSerializer<FileTransmissionObject>>(FileTransmissionObjectsTable)) {
                    var value = row.Value;
                    if (value == null) {
                        continue;
                    }

                    var data = value.Get;
                    if (data == null) {
                        continue;
                    }

                    if (data.LocalPath == localPath) {
                        return data;
                    }
                }
            }

            return null;
        }

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);
 }