private static void UpdateCache()
 {
     //the registry looks like:
     //[HKCR\ActivatableClasses\Package\<Identity_Version_Arch..._Token>\Server\<ServerId(ignored)>\]
     //AppUserModelId = User model Id (string)
     //ActivatableClasses = string[]
     //--------------------
     //Package 1<->n Server
     lock (SyncObject)
     {
         const string package = @"ActivatableClasses\Package";
         var k = Registry.ClassesRoot.OpenSubKey(package);
         if (k == null)
         {
             throw new Exception("Unable to open " + package + " key.");
         }
         Packages.Clear();
         foreach (var subkeyName in k.GetSubKeyNames()) //for each package in registry...
         {
             AppxServer[] servers;
             using (var packageKey = k.OpenSubKey(subkeyName + "\\Server")) //if server is available (i.e. is Activatable)
             {
                 if(packageKey == null)
                     continue;
                 var serverNames = packageKey.GetSubKeyNames();
                 servers = new AppxServer[serverNames.Length];
                 for (int i = 0; i < serverNames.Length; i++) //for each server in package...
                 {
                     using (var serverKey = packageKey.OpenSubKey(serverNames[i]))
                     {
                         if (serverKey == null)
                             continue;
                         servers[i] =                    //Create AppxServer
                             new AppxServer
                             {
                                 AppUserModelId = (string) serverKey.GetValue("AppUserModelId"),
                                 ActivatableClasses = (string[])serverKey.GetValue("ActivatableClasses")
                             };
                     }
                 }
             }
             var data = subkeyName.Split('_');
             var pack = new AppxPackage                  //Create AppxPackage with generated Servers list
                        {
                            Identity = data[0],
                            Servers = servers
                        };
             if (data.Length >= 4)
             {
                 pack.Version = new Version(data[1]);
                 pack.Architecture = data[2];
                 pack.Token = data[data.Length - 1];
             }
             Packages.Add(pack.Identity, pack);          //Add to cache
             Log.Raw("Added package to cache: " + pack);
         }
         k.Dispose();
     }
 }
Example #2
0
 private static void UpdateCache()
 {
     //the registry looks like:
     //[HKCR\ActivatableClasses\Package\<Identity_Version_Arch..._Token>\Server\<ServerId(ignored)>\]
     //AppUserModelId = User model Id (string)
     //ActivatableClasses = string[]
     //--------------------
     //Package 1<->n Server
     lock (SyncObject)
     {
         const string package = @"ActivatableClasses\Package";
         var          k       = Registry.ClassesRoot.OpenSubKey(package);
         if (k == null)
         {
             throw new Exception("Unable to open " + package + " key.");
         }
         Packages.Clear();
         foreach (var subkeyName in k.GetSubKeyNames()) //for each package in registry...
         {
             AppxServer[] servers;
             using (var packageKey = k.OpenSubKey(subkeyName + "\\Server")) //if server is available (i.e. is Activatable)
             {
                 if (packageKey == null)
                 {
                     continue;
                 }
                 var serverNames = packageKey.GetSubKeyNames();
                 servers = new AppxServer[serverNames.Length];
                 for (int i = 0; i < serverNames.Length; i++) //for each server in package...
                 {
                     using (var serverKey = packageKey.OpenSubKey(serverNames[i]))
                     {
                         if (serverKey == null)
                         {
                             continue;
                         }
                         servers[i] =                    //Create AppxServer
                                      new AppxServer
                         {
                             AppUserModelId     = (string)serverKey.GetValue("AppUserModelId"),
                             ActivatableClasses = (string[])serverKey.GetValue("ActivatableClasses")
                         };
                     }
                 }
             }
             var data = subkeyName.Split('_');
             var pack = new AppxPackage                  //Create AppxPackage with generated Servers list
             {
                 Identity = data[0],
                 Servers  = servers
             };
             if (data.Length >= 4)
             {
                 pack.Version      = new Version(data[1]);
                 pack.Architecture = data[2];
                 pack.Token        = data[data.Length - 1];
             }
             Packages.Add(pack.Identity, pack);          //Add to cache
             Log.Raw("Added package to cache: " + pack);
         }
         k.Dispose();
     }
 }