예제 #1
0
        public FileDataService(
            IDirectoryDataService directorySetupService,
            INotificationCenterService notificationCenterService,
            ISettingsService settingsService)
            : base(settingsService, notificationCenterService)
        {
            this._directorySetupService     = directorySetupService;
            this._notificationCenterService = notificationCenterService;
            this._settingsService           = settingsService;
            _getFullFileInfo = this._directorySetupService
                               .Get()
                               .Connect()
                               .LeftJoinMany(
                this.cache.Connect(),
                (dirSetup) => dirSetup.DirectorySetupId,
                (left, right) => right.Items.Select(item => new FileInfoEx(left, item))
                )
                               .TransformMany(x => x, x => x.FileInfo.Id)
                               .TakeUntil(destroy)
                               .AsObservableCache();

            _getFullFIleInfoByHash = this._getFullFileInfo
                                     .Connect()
                                     .Filter(file => FileInfoHashKey.CanBuild(file.FileInfo))
                                     .ChangeKey(file => file.FileInfo.HashKey.Value)
                                     .AsObservableCache();

            _fileHashCache = this.cache
                             .Connect()
                             .Filter(file => file.FileHash.HasValue && file.IsAccessible)
                             .ChangeKey(file => file.HashKey.Value)
                             .AsObservableCache();
        }
예제 #2
0
 public FileInfo(
     Uri path, DateTime creationTime, FileHash?fileHash, DateTime lastWriteTime, DirectorySetupId directorySetupId, long fileSize,
     bool isAccessible, FileInfoId id, DateTime created, DateTime?lastChange = null)
 {
     this.Path             = path;
     this.FileCreationTime = creationTime;
     this.FileHash         = fileHash;
     this.LastWriteTime    = lastWriteTime;
     this.DirectorySetupId = directorySetupId;
     this.FileSize         = fileSize;
     this.IsAccessible     = isAccessible;
     this.Id         = id;
     this.Created    = created;
     this.LastChange = lastChange ?? DateTime.Now;
     this.Identity   = Guid.NewGuid();
     this.HashKey    = null;
     if (FileInfoHashKey.CanBuild(this))
     {
         this.HashKey = new FileInfoHashKey(this);
     }
 }