Example #1
0
        public static ManifestEntry ConvertToManifestEntry(this ManifestDbEntry item, ManifestEntryType includeType, bool isEncrypted)
        {
            ManifestEntry result = default;

            var propertyList = new BinaryPropertyListReader()
                               .LoadFrom(item.Properties);

            if (propertyList != null && propertyList is IReadOnlyDictionary <string, object> )
            {
                dynamic properties = propertyList;

                var mode      = (int)properties["$objects"][1]["Mode"];
                var entryType = CommonHelpers.GetManifestEntryTypeFromMode(mode);
                if (entryType == includeType)
                {
                    var id = item.FileID;

                    result = new ManifestEntry
                    {
                        Id           = id,
                        Domain       = item.Domain,
                        RelativePath = item.RelativePath,
                        EntryType    = entryType,
                    };

                    if (isEncrypted)
                    {
                        var protectionClass = (ProtectionClass)properties["$objects"][1]["ProtectionClass"];
                        var index           = (int)properties["$objects"][1]["EncryptionKey"];
                        var data            = (byte[])properties["$objects"][index]["NS.data"];

                        result.ProtectionClass = protectionClass;
                        result.WrappedKey      = WrappedKeyReader.Read(data);
                    }
                }
            }

            return(result);
        }
Example #2
0
 public static void Write(this ILogger logger, ManifestEntry item)
 {
     logger.LogInformation("{Id},{Domain},{RelativePath},{Type}", item.Id, item.Domain, item.RelativePath, item.EntryType);
 }
Example #3
0
 public static void ConsoleWrite(this ManifestEntry item)
 {
     Console.WriteLine($"ID={item.Id},Domain='{item.Domain}',RelativePath='{item.RelativePath}',Type={item.EntryType}");
 }