public IEnumerable <ExtractedPackageDto> GetPackages(PostedDataDto postedData) { using (var inputStream = fileService.GetFileStream(postedData.guid)) using (MetadataContext context = new MetadataContext(inputStream, postedData.password)) { var packages = new List <ExtractedPackageDto>(); foreach (var package in context.GetPackages()) { List <PropertyDto> properties = new List <PropertyDto>(); List <KnownPropertyDto> descriptors = new List <KnownPropertyDto>(); foreach (var property in package.Properties) { properties.Add(new PropertyDto { name = property.Name, value = property.Value is Array ? ArrayUtil.AsString((Array)property.Value) : property.Value, type = (int)property.Type, }); } foreach (var descriptor in package.Descriptors) { var accessLevel = descriptor.AccessLevel; if (arrayTypes.Contains(descriptor.Type)) { accessLevel &= AccessLevels.Remove; } descriptors.Add(new KnownPropertyDto { name = descriptor.Name, type = (int)descriptor.Type, accessLevel = (int)accessLevel }); } packages.Add(new ExtractedPackageDto { id = package.Id, name = package.Name, index = package.Index, type = (int)package.Type, properties = properties, knownProperties = descriptors, }); } return(packages); } }