Exemplo n.º 1
0
 internal AddOn(AddOnManager addOnManager, Guid key, AddOnManifestEntry addOnManifestEntry) : this(addOnManager, key, false)
 {
     addOnPageUrl        = addOnManifestEntry.AddOnPageUrl;
     authorEmail         = addOnManifestEntry.AuthorEmail;
     authorName          = addOnManifestEntry.AuthorName;
     authorPageUrl       = addOnManifestEntry.AuthorPageUrl;
     description         = addOnManifestEntry.Description;
     donationsUrl        = addOnManifestEntry.DonationsUrl;
     iconUrl             = addOnManifestEntry.IconUrl;
     isPrereleaseVersion = addOnManifestEntry.IsPrereleaseVersion;
     name         = addOnManifestEntry.Name;
     flavor       = addOnManifestEntry.Flavor;
     sourceBranch = addOnManifestEntry.SourceBranch;
     sourceUrl    = addOnManifestEntry.SourceUrl;
     supportUrl   = addOnManifestEntry.SupportUrl;
     SaveState();
 }
Exemplo n.º 2
0
 internal AddOn(AddOnManager addOnManager, Guid key, bool loadState)
 {
     Key = key;
     this.addOnManager = addOnManager;
     if (this.addOnManager.AddOnsDirectory != null)
     {
         var path = Path.Combine(this.addOnManager.AddOnsDirectory.FullName, Key.ToString("N"));
         stateFile           = new FileInfo($"{path}.json");
         repositoryDirectory = new DirectoryInfo(path);
     }
     if (loadState)
     {
         AddOnState state;
         using (var streamReader = File.OpenText(stateFile.FullName))
             using (var jsonReader = new JsonTextReader(streamReader))
                 state = JsonSerializer.CreateDefault().Deserialize <AddOnState>(jsonReader);
         addOnPageUrl        = state.AddOnPageUrl;
         authorEmail         = state.AuthorEmail;
         authorName          = state.AuthorName;
         authorPageUrl       = state.AuthorPageUrl;
         description         = state.Description;
         donationsUrl        = state.DonationsUrl;
         iconUrl             = state.IconUrl;
         isLicenseAgreed     = state.IsLicenseAgreed;
         isPrereleaseVersion = state.IsPrereleaseVersion;
         license             = state.License;
         name   = state.Name;
         flavor = state.Flavor;
         savedVariablesAddOnNames             = state.SavedVariablesAddOnNames?.ToImmutableArray();
         savedVariablesPerCharacterAddOnNames = state.SavedVariablesPerCharacterAddOnNames?.ToImmutableArray();
         sourceBranch = state.SourceBranch;
         sourceUrl    = state.SourceUrl;
         supportUrl   = state.SupportUrl;
         var worldOfWarcraftInstallation = this.addOnManager.WorldOfWarcraftInstallation;
         if (worldOfWarcraftInstallation != null && worldOfWarcraftInstallation.ClientByFlavor.TryGetValue(flavor, out var client))
         {
             var clientPath = client.Directory.FullName;
             installedFiles = state.InstalledFiles?.Select(installedFile => new FileInfo(Path.Combine(clientPath, installedFile))).ToImmutableArray();
             installedSha   = state.InstalledSha;
         }
     }
 }