Example #1
0
        private void UpdateFileInfo()
        {
            lock (_minorLock)
            {
                try
                {
                    switch (_fileType)
                    {
                    case FileTypes.Console:
                        _fileInfo = new FileInfoCache(LastPos);
                        break;

                    case FileTypes.Regular:
                        _fileInfo = new FileInfoCache(new FileInfo(_file));
                        break;

                    case FileTypes.ArchivedFile:
                        _fileInfo ??= new FileInfoCache(_file);
                        break;

                    default:
                        throw new InvalidOperationException(
                                  $"Unknown FileType {_fileType}");
                    }
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch
#pragma warning restore CA1031 // Do not catch general exception types
                {
                    _fileInfo = null;
                }
            }
        }
Example #2
0
        public SyncEntryViewModel(NavigationNodeViewModel navigationNodeViewModel, SyncEntry syncEntry, SyncRelationshipViewModel syncRelationship)
        {
            this.navigationNodeViewModel = navigationNodeViewModel;
            this.syncRelationship        = syncRelationship;
            this.SyncEntry = syncEntry;

            this.Name              = syncEntry.Name;
            this.LastModified      = syncEntry.EntryLastUpdatedDateTimeUtc;
            this.Size              = Convert.ToUInt64(syncEntry.OriginalSize);
            this.IsDirectory       = syncEntry.Type == SyncEntryType.Directory;
            this.SelectItemCommand = new DelegatedCommand(o => this.SelectItem());

            if (this.IsDirectory)
            {
                var fileInfo = FileInfoCache.GetFolderInfo();
                this.IconImageSource = fileInfo.SmallIcon;
                this.LargeIcon       = fileInfo.LargeIcon;
                this.TypeName        = "Folder";
                return;
            }

            int      lastIndex2 = this.Name.LastIndexOf(".", StringComparison.Ordinal);
            FileInfo fileInfo2  = FileInfoCache.GetFileInfo(this.Name.Substring(lastIndex2).ToLowerInvariant());

            this.IconImageSource = fileInfo2.SmallIcon;
            this.TypeName        = fileInfo2.TypeName;
        }