Mango.Nop.Libraries/Mango.Nop.Core/docs/NOP_DEPENDENCIES.md

2.4 KiB

NopDependencies Pattern

Part of Mango.Nop.Core. See Mango.Nop.Core/README.md for project overview.

Why

Mango.Nop.Core has zero nopCommerce runtime dependency. This allows it to be referenced by projects that don't have the full nopCommerce stack (e.g. Blazor/MAUI clients that only need DTOs and interfaces).

To achieve this, NopDependencies/ contains mirror copies of nopCommerce entity classes with the same namespace as the originals:

// In NopDependencies/BaseEntity.cs — same namespace as nopCommerce
namespace Nop.Core;
public abstract partial class BaseEntity : IBaseEntity
{
    public int Id { get; set; }
}

At compile time, projects referencing only Mango.Nop.Core get these mirror types. Projects with the full nopCommerce stack get the real types — they are type-compatible because they share the same namespace and shape.

Rules

  • DO NOT modify files in NopDependencies/ unless the nopCommerce version changes
  • DO NOT change namespaces — they must match the original nopCommerce types exactly
  • All mirror classes are partial — they can be extended but should not be modified directly

File List

File Namespace Type
BaseEntity.cs Nop.Core BaseEntity (abstract, IBaseEntity) + IBaseEntity interface
Catalogs/Customer.cs Nop.Core.Domain.Customers Customer
Catalogs/CustomerRole.cs Nop.Core.Domain.Customers CustomerRole
Catalogs/Order.cs Nop.Core.Domain.Orders Order
Catalogs/OrderItem.cs Nop.Core.Domain.Orders OrderItem
Catalogs/OrderNote.cs Nop.Core.Domain.Orders OrderNote
Catalogs/Product.cs Nop.Core.Domain.Catalog Product
Catalogs/GenericAttribute.cs Nop.Core.Domain.Common GenericAttribute
Catalogs/StockQuantityHistory.cs Nop.Core.Domain.Catalog StockQuantityHistory
Catalogs/DiscountMapping.cs Nop.Core.Domain.Catalog DiscountMapping
Catalogs/DiscountProductMapping.cs Nop.Core.Domain.Catalog DiscountProductMapping

Enums: OrderStatus, PaymentStatus, ShippingStatus, ProductType, ManageInventoryMethod, BackorderMode, LowStockActivity, GiftCardType, RentalPricePeriod, RecurringProductCyclePeriod, DownloadActivationType, TaxDisplayType, VatNumberStatus

Interfaces: ISoftDeletedEntity, ILocalizedEntity, ISlugSupported, IAclSupported, IStoreMappingSupported, IDiscountSupported