Added Banggood shop.

This commit is contained in:
2021-05-11 01:52:57 -05:00
parent 04d4caf2bd
commit e675962c35
14 changed files with 302 additions and 16 deletions

View File

@@ -70,7 +70,7 @@ namespace MultiShop.DataStructures
set
{
if (value == false && !CanDisableShop()) return;
if (value == false && !(shopsEnabled.Count > 1)) return;
if (value)
{
shopsEnabled.Add(name);
@@ -81,8 +81,8 @@ namespace MultiShop.DataStructures
}
}
}
public bool CanDisableShop() {
return shopsEnabled.Count > 1;
public bool IsToggleable(string shop) {
return (shopsEnabled.Contains(shop) && shopsEnabled.Count > 1) || !shopsEnabled.Contains(shop);
}
}
}

View File

@@ -109,7 +109,7 @@
@foreach (string shop in Shops.Keys)
{
<div class="form-group form-check my-2">
<input class="form-check-input" type="checkbox" id=@(shop + "Checkbox") @bind="activeProfile.shopStates[shop]" disabled="@(!activeProfile.shopStates.CanDisableShop())">
<input class="form-check-input" type="checkbox" id=@(shop + "Checkbox") @bind="activeProfile.shopStates[shop]" disabled="@(!activeProfile.shopStates.IsToggleable(shop))">
<label class="form-check-label" for=@(shop + "Checkbox")>@shop enabled</label>
</div>
}
@@ -330,7 +330,7 @@
if (listing.Shipping == null && !activeProfile.keepUnknownShipping || (activeProfile.enableMaxShippingFee && listing.Shipping > activeProfile.MaxShippingFee)) continue;
float shippingDifference = listing.Shipping != null ? listing.Shipping.Value : 0;
if (!(listing.LowerPrice + shippingDifference >= activeProfile.lowerPrice && (!activeProfile.enableUpperPrice || listing.UpperPrice + shippingDifference <= activeProfile.UpperPrice))) continue;
if ((listing.Rating == null && !activeProfile.keepUnrated) || activeProfile.minRating > (listing.Rating == null ? 0 : listing.Rating)) continue;
if ((listing.Rating == null && !activeProfile.keepUnrated) && activeProfile.minRating > (listing.Rating == null ? 0 : listing.Rating)) continue;
if ((listing.PurchaseCount == null && !activeProfile.keepUnknownPurchaseCount) || activeProfile.minPurchases > (listing.PurchaseCount == null ? 0 : listing.PurchaseCount)) continue;
if ((listing.ReviewCount == null && !activeProfile.keepUnknownRatingCount) || activeProfile.minReviews > (listing.ReviewCount == null ? 0 : listing.ReviewCount)) continue;

View File

@@ -25,6 +25,7 @@
private bool modulesLoaded = false;
private Dictionary<string, IShop> shops = new Dictionary<string, IShop>();
private Dictionary<string, Assembly> unusedDependencies = new Dictionary<string, Assembly>();
protected override async Task OnInitializedAsync()
{
@@ -48,7 +49,7 @@
foreach (Task<byte[]> task in assemblyDownloadTasks)
{
Assembly assembly = AppDomain.CurrentDomain.Load(await task);
bool assigned = false;
foreach (Type type in assembly.GetTypes())
{
if (typeof(IShop).IsAssignableFrom(type)) {
@@ -58,17 +59,34 @@
shops.Add(shop.ShopName, shop);
Logger.Log($"Registered and started lifetime of module for \"{shop.ShopName}\".", LogLevel.Debug);
}
assigned = true;
}
}
if (!assigned) {
unusedDependencies.Add(assembly.FullName, assembly);
Logger.Log($"Assembly \"{assembly.FullName}\" did not contain a shop module. Storing it as potential extension.", LogLevel.Debug);
}
}
foreach (string assembly in unusedDependencies.Keys)
{
Logger.Log($"{assembly} was unused.", LogLevel.Warning);
}
unusedDependencies.Clear();
modulesLoaded = true;
}
private Assembly OnAssemblyDependencyRequest(object sender, ResolveEventArgs args) {
Logger.Log($"Assembly {args.RequestingAssembly} is requesting dependency assembly {args.Name}. Attempting to retrieve...", LogLevel.Debug);
return AppDomain.CurrentDomain.Load(Http.GetByteArrayAsync(Configuration["ModulesDir"] + args.Name + ".dll").Result);
Logger.Log($"Assembly {args.RequestingAssembly} is requesting dependency assembly {args.Name}.", LogLevel.Debug);
if (unusedDependencies.ContainsKey(args.Name))
{
Logger.Log("Dependency found.", LogLevel.Debug);
Assembly dependency = unusedDependencies[args.Name];
unusedDependencies.Remove(args.Name);
return dependency;
}
Logger.Log($"No dependency under name {args.Name}", LogLevel.Debug);
return null;
}

Binary file not shown.

Binary file not shown.

View File

@@ -1,3 +1,5 @@
[
"AliExpressShop"
"AliExpressShop",
"HtmlAgilityPack",
"BanggoodShop"
]