/// <summary> /// Maps the <see cref="OfferComponentDefinition"/> to a <see cref="OfferComponentConfiguration"/> so /// that it can be serialized and saved to the database as JSON more easily. /// </summary> /// <param name="definition"> /// The definition. /// </param> /// <returns> /// The <see cref="OfferComponentConfiguration"/>. /// </returns> internal static OfferComponentConfiguration AsOfferComponentConfiguration(this OfferComponentDefinition definition) { if (!OfferComponentResolver.HasCurrent) { throw new NullReferenceException("The OfferComponentResolver singleton has not been instantiated"); } var type = OfferComponentResolver.Current.GetTypeByComponentKey(definition.ComponentKey); if (type != null) { return(new OfferComponentConfiguration() { OfferSettingsKey = definition.OfferSettingsKey, OfferCode = definition.OfferCode, ComponentKey = definition.ComponentKey, TypeFullName = type.FullName, Values = definition.ExtendedData.AsEnumerable().ToArray() }); } var nullRef = new NullReferenceException("Was not able to resolve the OfferComponentType with key: " + definition.ComponentKey); MultiLogHelper.Error(typeof(Extensions), "Unable to resolve OfferCompoent", nullRef); throw nullRef; }
public void Can_Resolve_An_OfferComponent_By_Type() { var config = new OfferComponentConfiguration() { ComponentKey = new Guid("A035E592-5D09-40BD-BFF6-73C3A4E9DDA2"), TypeFullName = typeof(OneCouponPerCustomerConstraint).Name, Values = Enumerable.Empty <KeyValuePair <string, string> >() }; var definition = new OfferComponentDefinition(config); var resolved = _resolver.GetOfferComponent <OneCouponPerCustomerConstraint>(definition); Assert.NotNull(resolved); }
/// <summary> /// Initializes a new instance of the <see cref="ExcludeTaxesIncludedInProductPrices"/> class. /// </summary> /// <param name="definition"> /// The definition. /// </param> public ExcludeTaxesIncludedInProductPrices(OfferComponentDefinition definition) : base(definition) { }
/// <summary> /// Initializes a new instance of the <see cref="OfferRewardComponentBase"/> class. /// </summary> /// <param name="definition"> /// The definition. /// </param> protected OfferRewardComponentBase(OfferComponentDefinition definition) : base(definition) { }
/// <summary> /// Initializes a new instance of the <see cref="ProductSelectionFilterConstraint"/> class. /// </summary> /// <param name="settings"> /// The settings. /// </param> public ProductSelectionFilterConstraint(OfferComponentDefinition settings) : base(settings) { }
/// <summary> /// Initializes a new instance of the <see cref="CouponDiscountLineItemReward"/> class. /// </summary> /// <param name="definition"> /// The <see cref="OfferComponentDefinition"/>. /// </param> public CouponDiscountLineItemReward(OfferComponentDefinition definition) : base(definition) { }
/// <summary> /// Initializes a new instance of the <see cref="CollectionAlterationCouponConstraintBase"/> class. /// </summary> /// <param name="definition"> /// The definition. /// </param> protected CollectionAlterationCouponConstraintBase(OfferComponentDefinition definition) : base(definition) { }
/// <summary> /// Initializes a new instance of the <see cref="ExcludeShippingCostConstraint"/> class. /// </summary> /// <param name="definition"> /// The definition. /// </param> public ExcludeShippingCostConstraint(OfferComponentDefinition definition) : base(definition) { }
/// <summary> /// Initializes a new instance of the <see cref="LineItemPriceFilterRulesConstraint"/> class. /// </summary> /// <param name="definition"> /// The definition. /// </param> public LineItemPriceFilterRulesConstraint(OfferComponentDefinition definition) : base(definition) { }
/// <summary> /// Initializes a new instance of the <see cref="OneCouponPerCustomerConstraint"/> class. /// </summary> /// <param name="definition"> /// The <see cref="OfferComponentDefinition"/>. /// </param> public OneCouponPerCustomerConstraint(OfferComponentDefinition definition) : base(definition) { }
/// <summary> /// Initializes a new instance of the <see cref="CanBeUsedWithOtherCouponsConstraint"/> class. /// </summary> /// <param name="definition"> /// The <see cref="OfferComponentDefinition"/>. /// </param> public CanBeUsedWithOtherCouponsConstraint(OfferComponentDefinition definition) : base(definition) { }
/// <summary> /// Initializes a new instance of the <see cref="ExcludeProductsOnSaleConstraintVisitor"/> class. /// </summary> /// <param name="settings"> /// The settings. /// </param> public ExcludeProductsOnSaleConstraint(OfferComponentDefinition settings) : base(settings) { }
/// <summary> /// Initializes a new instance of the <see cref="MaximumQuantityConstraint"/> class. /// </summary> /// <param name="definition"> /// The definition. /// </param> public MaximumQuantityConstraint(OfferComponentDefinition definition) : base(definition) { }
/// <summary> /// Initializes a new instance of the <see cref="MaximumNumberOfRedemptionsConstraint"/> class. /// </summary> /// <param name="definition"> /// The definition. /// </param> public MaximumNumberOfRedemptionsConstraint(OfferComponentDefinition definition) : base(definition) { }
/// <summary> /// Initializes a new instance of the <see cref="CollectionQuantityRulesConstraint"/> class. /// </summary> /// <param name="definition"> /// The definition. /// </param> public CollectionQuantityRulesConstraint(OfferComponentDefinition definition) : base(definition) { }
/// <summary> /// Initializes a new instance of the <see cref="NotUsableWithOtherCouponsConstraint"/> class. /// </summary> /// <param name="definition"> /// The <see cref="OfferComponentDefinition"/>. /// </param> public NotUsableWithOtherCouponsConstraint(OfferComponentDefinition definition) : base(definition) { }
/// <summary> /// Initializes a new instance of the <see cref="NotUsableByAnonymousCustomersConstraint"/> class. /// </summary> /// <param name="definition"> /// The definition. /// </param> public NotUsableByAnonymousCustomersConstraint(OfferComponentDefinition definition) : base(definition) { }
/// <summary> /// Initializes a new instance of the <see cref="CouponDiscountLineItemRewardBase"/> class. /// </summary> /// <param name="definition"> /// The definition. /// </param> protected CouponDiscountLineItemRewardBase(OfferComponentDefinition definition) : base(definition) { }
/// <summary> /// Initializes a new instance of the <see cref="OfferConstraintComponentBase"/> class. /// </summary> /// <param name="definition"> /// The definition. /// </param> protected OfferConstraintComponentBase(OfferComponentDefinition definition) : base(definition) { }
/// <summary> /// Initializes a new instance of the <see cref="CouponFreeShippingReward"/> class. /// </summary> /// <param name="definition"> /// The definition. /// </param> public CouponFreeShippingReward(OfferComponentDefinition definition) : base(definition) { }
/// <summary> /// Initializes a new instance of the <see cref="CollectionPriceRulesConstraint"/> class. /// </summary> /// <param name="definition"> /// The definition. /// </param> public CollectionPriceRulesConstraint(OfferComponentDefinition definition) : base(definition) { }