コード例 #1
0
        public IEnumerable <FileProperty> ProvideValues(FileInfo fileInfo, FilePropertiesDto dto)
        {
            dto.OpenWithProgramPath = AssocQueryString(AssocStr.Executable, fileInfo.Extension);
            dto.OpenWithProgramName = AssocQueryString(AssocStr.FriendlyAppName, fileInfo.Extension);

            return(Enumerable.Empty <FileProperty>());
        }
コード例 #2
0
        public IEnumerable <FileProperty> ProvideValues(FileInfo fileInfo, FilePropertiesDto dto)
        {
            using (var shellObject = ShellObject.FromParsingName(fileInfo.FullName))
            {
                if (shellObject == null)
                {
                    yield break;
                }

                foreach (var property in shellObject.Properties.DefaultPropertyCollection)
                {
                    if (string.IsNullOrEmpty(property.CanonicalName))
                    {
                        continue;
                    }

                    var(valueString, valueType) = ObjectToString(property.ValueAsObject);
                    if (string.IsNullOrEmpty(valueString))
                    {
                        continue;
                    }

                    yield return(new FileProperty
                    {
                        FormatId = property.PropertyKey.FormatId,
                        PropertyId = property.PropertyKey.PropertyId,
                        Name = property.CanonicalName,
                        Value = valueString,
                        ValueType = valueType,
                        Group = GetGroup(property)
                    });
                }
            }
        }
コード例 #3
0
ファイル: TrustedProvider.cs プロジェクト: 5l1v3r1/Maze-1
 public IEnumerable <FileProperty> ProvideValues(FileInfo fileInfo, FilePropertiesDto dto)
 {
     yield return(new FileProperty
     {
         Name = "IsTrusted",
         Value = AuthenticodeTools.IsTrusted(fileInfo.FullName).ToString(),
         Group = FilePropertyGroup.Executable
     });
 }
コード例 #4
0
        public IEnumerable <FileProperty> ProvideValues(FileInfo fileInfo, FilePropertiesDto dto)
        {
            dto.Size           = fileInfo.Length;
            dto.CreationTime   = fileInfo.CreationTimeUtc;
            dto.LastAccessTime = fileInfo.LastAccessTimeUtc;
            dto.LastWriteTime  = fileInfo.LastWriteTimeUtc;
            dto.Attributes     = fileInfo.Attributes;

            return(Enumerable.Empty <FileProperty>());
        }
コード例 #5
0
        public void Initialize(FileViewModel fileViewModel, FilePropertiesDto dto, ITargetedRestClient restClient)
        {
            var properties = GeneralPropertyViewModel.CreateFileProperties(fileViewModel, dto).ToList();

            GeneralProperties = CreateGeneralProperties(properties);
            Entry             = fileViewModel;
            DetailsViewModel  = new DetailsPropertyViewModel(dto.Properties);

            if (!Entry.IsDirectory)
            {
                HashViewModels = Enum.GetValues(typeof(FileHashAlgorithm)).Cast <FileHashAlgorithm>()
                                 .Select(x => new ComputeHashViewModel(Entry.Source.Path, x, restClient)).ToList();
            }
        }
コード例 #6
0
        public IEnumerable <FileProperty> ProvideValues(FileInfo fileInfo, FilePropertiesDto dto)
        {
            var assemblyName = AssemblyName.GetAssemblyName(fileInfo.FullName);

            yield return(new FileProperty
            {
                Name = "IsAssembly",
                Value = true.ToString(),
                Group = FilePropertyGroup.Executable
            });

            yield return(new FileProperty
            {
                Name = "AssemblyName",
                Value = assemblyName.FullName,
                Group = FilePropertyGroup.Executable
            });

            yield return(new FileProperty
            {
                Name = "AssemblyProcessorArchitecture",
                Value = assemblyName.ProcessorArchitecture.ToString(),
                Group = FilePropertyGroup.Executable
            });

            yield return(new FileProperty
            {
                Name = "AssemblyHashAlgorithm",
                Value = assemblyName.HashAlgorithm.ToString(),
                Group = FilePropertyGroup.Executable
            });

            if ((assemblyName.Flags & AssemblyNameFlags.PublicKey) != 0)
            {
                yield return(new FileProperty
                {
                    Name = "AssemblyPublicKeyToken",
                    Value = BitConverter.ToString(assemblyName.GetPublicKeyToken()),
                    Group = FilePropertyGroup.Executable
                });

                yield return(new FileProperty
                {
                    Name = "AssemblyPublicKey",
                    Value = BitConverter.ToString(assemblyName.GetPublicKey()),
                    Group = FilePropertyGroup.Executable
                });
            }
        }
コード例 #7
0
        public async Task <IActionResult> GetFileProperties([FromQuery] string path, [FromServices] IEnumerable <IFilePropertyValueProvider> propertyValueProviders)
        {
            var result     = new FilePropertiesDto();
            var fileInfo   = new FileInfo(path);
            var properties = new ConcurrentBag <FileProperty>();

            await TaskCombinators.ThrottledCatchErrorsAsync(propertyValueProviders, (provider, token) => Task.Run(() =>
            {
                foreach (var fileProperty in provider.ProvideValues(fileInfo, result).ToList())
                {
                    properties.Add(fileProperty);
                }
            }), CancellationToken.None);

            result.Properties = properties.ToList();
            return(Ok(result));
        }
コード例 #8
0
        public IEnumerable <FileProperty> ProvideValues(FileInfo fileInfo, FilePropertiesDto dto)
        {
            var fileVersionInfo = FileVersionInfo.GetVersionInfo(fileInfo.FullName);

            foreach (var propertyInfo in typeof(FileVersionInfo).GetProperties())
            {
                if (propertyInfo.Name.EndsWith("Part"))
                {
                    continue;
                }

                var value = propertyInfo.GetValue(fileVersionInfo, null);
                if (value == null)
                {
                    continue;
                }

                if (propertyInfo.PropertyType == typeof(bool) && !(bool)value)
                {
                    continue;
                }

                var(valueString, valueType) = ObjectToString(value);
                if (string.IsNullOrEmpty(valueString))
                {
                    continue;
                }

                yield return(new FileProperty
                {
                    Name = propertyInfo.Name,
                    Value = valueString,
                    ValueType = valueType,
                    Group = FilePropertyGroup.Details
                });
            }
        }
コード例 #9
0
ファイル: DiskSizeProvider.cs プロジェクト: 5l1v3r1/Maze-1
 public IEnumerable <FileProperty> ProvideValues(FileInfo fileInfo, FilePropertiesDto dto)
 {
     dto.SizeOnDisk = GetFileSizeOnDisk(fileInfo);
     return(Enumerable.Empty <FileProperty>());
 }