Made progress on implementing some shops.
Performed some folder restructuring as well.
This commit is contained in:
85
Props-Modules/Props.Shop/Framework/Filters.cs
Normal file
85
Props-Modules/Props.Shop/Framework/Filters.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
|
||||
namespace Props.Shop.Framework
|
||||
{
|
||||
public class Filters
|
||||
{
|
||||
public Currency Currency { get; set; } = Currency.CAD;
|
||||
public float MinRating { get; set; } = 0.8f;
|
||||
public bool KeepUnrated { get; set; } = true;
|
||||
public bool EnableUpperPrice { get; set; } = false;
|
||||
private int upperPrice;
|
||||
|
||||
public int UpperPrice
|
||||
{
|
||||
get
|
||||
{
|
||||
return upperPrice;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (EnableUpperPrice) upperPrice = value;
|
||||
}
|
||||
}
|
||||
public int LowerPrice { get; set; }
|
||||
public int MinPurchases { get; set; }
|
||||
public bool KeepUnknownPurchaseCount { get; set; } = true;
|
||||
public int MinReviews { get; set; }
|
||||
public bool KeepUnknownRatingCount { get; set; } = true;
|
||||
public bool EnableMaxShippingFee { get; set; }
|
||||
private int maxShippingFee;
|
||||
|
||||
public int MaxShippingFee
|
||||
{
|
||||
get
|
||||
{
|
||||
return maxShippingFee;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (EnableMaxShippingFee) maxShippingFee = value;
|
||||
}
|
||||
}
|
||||
public bool KeepUnknownShipping { get; set; } = true;
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || GetType() != obj.GetType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Filters other = (Filters)obj;
|
||||
return
|
||||
Currency == other.Currency &&
|
||||
MinRating == other.MinRating &&
|
||||
KeepUnrated == other.KeepUnrated &&
|
||||
EnableUpperPrice == other.EnableUpperPrice &&
|
||||
UpperPrice == other.UpperPrice &&
|
||||
LowerPrice == other.LowerPrice &&
|
||||
MinPurchases == other.MinPurchases &&
|
||||
KeepUnknownPurchaseCount == other.KeepUnknownPurchaseCount &&
|
||||
MinReviews == other.MinReviews &&
|
||||
KeepUnknownRatingCount == other.KeepUnknownRatingCount &&
|
||||
EnableMaxShippingFee == other.EnableMaxShippingFee &&
|
||||
MaxShippingFee == other.MaxShippingFee &&
|
||||
KeepUnknownShipping == other.KeepUnknownShipping;
|
||||
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(
|
||||
Currency,
|
||||
MinRating,
|
||||
UpperPrice,
|
||||
LowerPrice,
|
||||
MinPurchases,
|
||||
MinReviews,
|
||||
MaxShippingFee);
|
||||
}
|
||||
public Filters Copy()
|
||||
{
|
||||
return (Filters)this.MemberwiseClone();
|
||||
}
|
||||
}
|
||||
}
|
14
Props-Modules/Props.Shop/Framework/IOption.cs
Normal file
14
Props-Modules/Props.Shop/Framework/IOption.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace Props.Shop.Framework
|
||||
{
|
||||
public interface IOption
|
||||
{
|
||||
public string Name { get; }
|
||||
public string Description { get; }
|
||||
public bool Required { get; }
|
||||
public string GetValue();
|
||||
public bool SetValue(string value);
|
||||
public Type Type { get; }
|
||||
}
|
||||
}
|
@@ -6,14 +6,16 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Props.Shop.Framework
|
||||
{
|
||||
public interface IShop : IAsyncEnumerable<ProductListing>, IDisposable
|
||||
public interface IShop : IDisposable
|
||||
{
|
||||
string ShopName { get; }
|
||||
string ShopDescription { get; }
|
||||
string ShopModuleAuthor { get; }
|
||||
|
||||
public void SetupSession(string query, Currency currency);
|
||||
public IAsyncEnumerable<ProductListing> Search(string query, Filters filters);
|
||||
|
||||
void Initialize();
|
||||
IEnumerable<IOption> Initialize(byte[] data);
|
||||
public SupportedFeatures SupportedFeatures { get; }
|
||||
public byte[] GetDataForPersistence();
|
||||
}
|
||||
}
|
@@ -12,5 +12,6 @@ namespace Props.Shop.Framework
|
||||
public int? PurchaseCount { get; set; }
|
||||
public int? ReviewCount { get; set; }
|
||||
public bool ConvertedPrices { get; set; }
|
||||
public bool? InStock { get; set; }
|
||||
}
|
||||
}
|
20
Props-Modules/Props.Shop/Framework/SupportedFeatures.cs
Normal file
20
Props-Modules/Props.Shop/Framework/SupportedFeatures.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace Props.Shop.Framework
|
||||
{
|
||||
public class SupportedFeatures
|
||||
{
|
||||
bool Shipping { get; }
|
||||
bool Rating { get; }
|
||||
bool ReviewCount { get; }
|
||||
bool PurchaseCount { get; }
|
||||
bool InStock { get; }
|
||||
|
||||
public SupportedFeatures(bool shipping, bool rating, bool reviewCount, bool purchaseCount, bool inStock)
|
||||
{
|
||||
this.Shipping = shipping;
|
||||
this.Rating = rating;
|
||||
this.ReviewCount = reviewCount;
|
||||
this.PurchaseCount = purchaseCount;
|
||||
this.InStock = inStock;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user