Ejemplo n.º 1
0
        public IEnumerable <ManifestDbEntry> GetAllItems()
        {
            var command = Connection.CreateCommand();

            command.CommandText = "SELECT "
                                  + "fileId,"
                                  + "domain,"
                                  + "relativePath,"
                                  + "flags,"
                                  + "file"
                                  + " FROM Files";

            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    var result = new ManifestDbEntry
                    {
                        FileID       = reader.GetString(0),
                        Domain       = reader.GetString(1),
                        RelativePath = reader.GetString(2),
                        Flags        = reader.GetInt32(3),
                        Properties   = (byte[])reader.GetValue(4)
                    };

                    yield return(result);
                }
            }

            Connection.Close();
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
 public static void ConsoleWrite(this ManifestDbEntry item)
 {
     Console.WriteLine($"FileID={item.FileID},Domain='{item.Domain}',RelativePath='{item.RelativePath}',Flags=0x{item.Flags:x4}");
 }